How to use the PriGrelha from the PRIMAVERA ERP SDK?
The SDK is a library of business standards and controls for the PRIMAVERA environment. It allows partners and external development teams to quickly and easily create add-ons for the ERP. The purse of this article is to describe how we can use one of these controls - the PriGrelha, as well as its loading and initialization process in a database query context (for example, a current account statement list). Query to execute: Step 1 - Initializing the SDK To use any SDK control, it must first be initialized (see article "How to use the ERP PRIMAVERA SDK controls?." Step 2 - Initialization with the SDK context After launching the PriGrelha control in the form, it needs to be initialized with the context of the SDK. This initialization must take place before any operation on the table. Step 3 - Format For the table to display results you need to format the respective columns, indicating which field to display for each one. These columns need to comply with the query that will be executed. The method used for this formatting is AddColKey from the PriGrelha, and these are the main arguments: In the general initialization of the PriGrelha you also need to indicate other attributes, such as: Groupings You need to specify if the grid will have groupings and how many are allowed. To do this, you must execute the following command line as many times as the number of groupings you want to allow for the grid (up to a maximum of four): Context menu By default, the context menu to display will be the standard menu named 'PopupGrelhasStd'. If you want to add new options to the menu, you need to create a specific menu. The instruction to define the context menu is: Title The table must have a title. The instruction to define the title is: Permissions There are some properties that indicate what operations are allowed on the table. Other table properties Step 4 - Loading the PriGrelha This article describes the simplest and easiest way to use a PriGrelha in a database query context, through an SQL query executed by DataBind. As explained above, the fields from the SELECT performed to get records for the table must match the created columns. The best way to ensure this is by using a method from the table itself to return all fields, following the structure created in the initialization method, which is already correctly formatted to be added to the SELECT. Example of how to perform the DataBind from a database query: If the 'PermiteDataFill' property is enabled, this event will be executed. It allows you to manipulate all the data being loaded into the table, line by line. There are other table events. These are the most important ones to consider: Here you can find a complete example of how to use the PriGrelha in editing mode.SELECT TipoEntidade, Entidade, Modulo, Filial, TipoDoc, Serie, NumDocInt, DataDoc, ValorTotal, ValorPendente
FROM Pendentes
ORDER BY TipoEntidade, Entidade, DataDoc
Using the PriGrelha
private void frmDemoGrid_Load(object sender, EventArgs e)
{
// Initialize the SDK context
PriSDKContext.Initialize(BSO, PSO);
// Initialize SDK controls
InitializeSDKControls();
// Initialize the grid
InitializeGrid();
}
ColKey The column's unique key Tipo Column type, which mus match the type of field (Integer, Float, Edit, etc.) Título Text that will be displayed in the column header Largura Width of the column Visível Indicates whether this column is visible or hidden CamposBaseDados Database field that will be used to retrieve the results. This can be a calculated value, such as: ValorPago = ValorTotal - ValorPendente DrillDown Indicates if the column will be formatted for drill-down priGrelha1.AddColAgrupa();
priGrelha1.BandaMenuContexto = 'PopupGrelhasStd';
priGrelha1.TituloGrelha = 'Demo Grid 1';
PermiteAgrupamentosUser Indicates whether the user can manipulate, create, change or remove the groupings. PermiteOrdenacao Indicates whether the user can sort the table PermiteActualizar Indicates whether the option to update the table data is available PermiteFiltros Indicates whether table data filters are available PermiteDetalhes Indicates whether the lateral details grid is allowed PermiteStatusBar Indicates whether the status bar is displayed PermiteDataFill Indicates whether the DataFill event is executed (explained below in this article) PermiteVistas Indicates whether views for the table data are allowed. Property Type Description BandaMenuContexto string Returns/defines the menu band with user options BotaoConfigurarActiveBar bool Returns/defines when the column configuration button is available in the internal menu bar CaminhoTemplateImpressao string Intenal. File with the printing template ColsFrozen int Number of non-editable columns NumeroMaxRegistosSemPag int Maximum number of records allowed without pagination (the table needs to allow pagination ('Permitir Paginação') NumeroRegistos int Returns/defines the number of table records NumLinhasCabecalho int Retorns/defines the number of header lines OrientacaoMapa enum Returns/sets the orientation of the table for printing ParentFormModal bool Returns/defines the way context options are presented PermiteActiveBar bool Returns/defines whether the table's internal menu bar is displayed PermiteConfigurarDetalhes bool Allows you to retrieve information on whether the details table can be configured PermiteContextoVazia bool Allows you to define whether the table allows Right-Click actions when it is empty PermiteEdicao bool Returns/defines whether the table allows column editing PermiteGrafico bool Returns/defines whether the graphics option is available PermiteGrandeTotal bool Returns/defines whether totalizers are displayed PermitePaginacao bool Allows you to activate the table paging when there is a lot of information PermiteScrollBars bool Returns/defines if the table adds scroll bars PosicionaColunaSeguinte bool Places the cursor on the next column TituloGrelha string Returns/defines the title of the table TituloMapa string Returns/defines the report title TypeNameLinha string Allows you to set the name of the object on the line for MostraBEO and PreencheBEO TypeNameLinhas string Allows you to set the name of the object on the lines for MostraBEO and PreencheBEO private void LoadGrid()
{
StdBELista lista;
StringBuilder query = new StringBuilder();
query.AppendLine(string.Format('SELECT {0}', priGrelha1.DaCamposBDSelect()));
query.AppendLine('FROM Pendentes');
query.AppendLine(string.Format('WHERE TipoEntidade = '{0}'', tiposEntidade1.TipoEntidade));
if (!string.IsNullOrWhiteSpace(f41.Text))
{
query.AppendLine(string.Format('AND Entidade = '{0}'', f41.Text));
}
query.AppendLine('ORDER BY DataDoc');
lista = new StdBELista();
lista = PriSDKContext.SdkContext.BSO.Consulta(query.ToString());
priGrelha1.DataBind(lista);
}
"DataFill" event
private void priGrelha1_DataFill(object Sender, PriGrelha.DataFillEventArgs e)
{
// Set modulo description
string modulo = PSO.Utils.FStr(priGrelha1.GetGRID_GetValorCelula(e.Row, colModulo));
string moduloDesc = modulo;
switch (modulo)
{
case 'V':
moduloDesc = 'Vendas';
break;
case 'C':
moduloDesc = 'Compras';
break;
case 'M':
moduloDesc = 'C/Corentes';
break;
default:
break;
}
priGrelha1.SetGRID_SetValorCelula(e.Row, colModuloDesc, moduloDesc);
// Set days of delay
int daysOfDelay = PSO.Utils.FInt(priGrelha1.GetGRID_GetValorCelula(e.Row, colDiasAtraso));
daysOfDelay = daysOfDelay < 0 ? Math.Abs(daysOfDelay) : 0;
priGrelha1.SetGRID_SetValorCelula(e.Row, colDiasAtraso, daysOfDelay);
}
Other events
priGrelha1_ActualizaDados Event triggered by the table when refresh is clicked priGrelha1_FormatacaoAlterada Event triggered by the table after changes are made to the configuration priGrelha1_MenuContextoSeleccionado Event triggered by the table when a context menu option is clicked
login para deixar a sua opinião.