Pular para o conteúdo principal

Grid

A sub namespace of UI, exclusive for grid operations

//accessing to ui.grid methods
SW.UI.Grid.{methodName}

addToolbarButtons

Description

This method can be to add buttons in the grid toolbar.

Method(s)

1 function addToolbarButtons(toolbarEvent: any, buttonsList: Button[]): void;
ParameterTypeRequiredDefaultsDescription
toolbarEventanytrueThe target dataGrid
buttonsListButtontrueButtons to add

Basic Usage

SW.UI.Grid.addToolbarButtons(toolbarEvent, buttonsList);

calculatePercentageSummary

Description

This method can be used to calculate summaries with percentages.

Method(s)

1 function calculatePercentageSummary(options: any, dividend: number[], divisor: number[]): void
ParameterTypeRequiredDefaultsDescription
optionsanytrueSummary options
dividendnumber[]trueArray of dividends
divisornumber[]trueArray of divisors

Basic Usage

SW.UI.Grid.calculatePercentageSummary(options, [1,2,3], [4,5,6]);

Response


delete

Description

This method can be used to delete grid rows.

Method(s)

1 function delete(documentName: string, dataGrid: dxDataGrid, params: { idField?: string } = {}): void 
ParameterTypeRequiredDefaultsDescription
documentNamestringtrueDocument name
dataGriddxDataGridtrueTarget datagrid
idFieldstringfalseField to delete

Basic Usage

SW.UI.Grid.delete("company", dataGrid);

expandCollapseRows

Description

This method can be used inside any workspace. To expand or collapse specified Grid rows.

Method(s)

1   function expandCollapseRows(dataGrid: dxDataGrid,
2 params: {
3 expandPriority?: boolean
4 } = {
5 expandPriority: true
6 }
7 ): void
ParameterTypeRequiredDefaultsDescription
dataGriddxDataGridtrueTarget datagrid
expandPrioritybooleanfalsetrueFlag to set if the rows are to expanded or collapsed instead

Basic Usage

SW.UI.grid.expandCollapseRow(dataGrid.component);

Response


exportToPdf

Description

This method allows the grid to be exported as PDF.

Method(s)

1 public exportToPdf(
dataGrid: dxDataGrid,
fileName: string,
pdfDataGridOptions: PdfExportDataGridProps = {},
pdfOptions?: jsPDFOptions
);
ParameterTypeRequiredDefaultsDescription
dataGriddxDataGridtrueTarget datagrid
fileNamestringtrueChosen file name
pdfDataGridOptionsPdfExportDataGridPropstruePDF Grid related options
pdfOptionsjsPDFOptionsfalsePDF exporting options

PdfExportDataGridProps

ParameterTypeRequiredDefaultsDescription
autoTableOptionsobjectfalseOptions of the generated PDF table. Refer to the jsPDF-autoTable plugin documentation to see the full list of available customizations.
selectedRowsOnlybooleanfalseSpecifies whether or not to export only selected rows.
keepColumnWidthsbooleanfalseSpecifies whether columns in the PDF file should have the same width as their source UI component's columns.

jsPDFOptions

ParameterTypeRequiredDefaultsDescription
orientationstringfalse"p" | "portrait" | "l" | "landscape"Defines the orientation of the grid.

Basic Usage

    SW.UI.Grid.exportToPdf(
workspaceContext.get("dataGrid"),
"Timesheet Report",
{
keepColumnWidths: true,
autoTableOptions: {
styles: { fontSize: 8 }
}
},
{ orientation: "landscape" });

Example

img-box-shadow

img-box-shadow


importExcel

Description

This method can be used to import a xlsx file into a datagrid.

Method(s)

1 function importExcel(fileUpload: any, grid: dxDataGrid): void;
ParameterTypeRequiredDefaultsDescription
fileUploadanytrueFile to be uploaded
dataGriddxDataGridtrueTarget datagrid

Basic Usage

SW.UI.grid.importExcel(file, grid);