Hello,
I'm using the grid and doing the initial grouping of the "Date" column, but I would like the default to be descending. How to adjust it?
Thanks
<ejs-grid id="GridProducaoEstoque"
allowTextWrap="true"
locale="pt"
height="100%"
allowSorting="true"
allowFiltering=true
allowExcelExport="true"
enablePersistence="true"
allowGrouping="true"
recordDoubleClick="doubleClickGridProducaoEstoque"
allowPaging="true"
toolbarClick="toolbarClick"
toolbar=toolbarItemsEstoqueGrid>
<e-data-manager url="/EstoqueMovimenta/UrlDataSource"
removeUrl="/EstoqueMovimenta/DeleteEstoqueMovimenta"
adaptor="UrlAdaptor">
</e-data-manager>
<e-grid-groupsettings columns="@(new string[] {"datamovimenta"})" allowReordering="true"></e-grid-groupsettings>
Hi Roberto,
Thanks for contacting Syncfusion support.
To group the columns in descending order at initial render, we suggest you to sort that columns in descending order in the initial settings of Grid to achieve your requirement.
Initial Sort: https://ej2.syncfusion.com/documentation/grid/sorting/#initial-sort
[index.cshtml] @{ List<object> cols = new List<object>(); cols.Add(new { field = "TrackedDate", direction = "Descending" }); }
<ejs-grid height="273" id="GridProducaoEstoque" created="created"> <e-grid-sortsettings columns="cols"></e-grid-sortsettings> <e-grid-groupsettings columns="@(new string[] {"TrackedDate"})" allowReordering="true"></e-grid-groupsettings> </ejs-grid>
|
If you want to Group the columns in descending order after the initial rendering, you can achieve this by overriding the following method in the created event of Grid.
Created: https://ej2.syncfusion.com/javascript/documentation/api/grid/#created
function created(args) { this.groupModule.groupAddSortingQuery = function (colName) { let i = 0; while (i < this.parent.sortSettings.columns.length) { if (this.parent.sortSettings.columns[i].field === colName) { break; } i++; } if (this.parent.sortSettings.columns.length === i) { this.parent.sortSettings.columns.push({ field: colName, direction: 'Descending', isFromGroup: true, }); } else if (!this.parent.allowSorting) { this.parent.sortSettings.columns[i].direction = 'Descending'; } } }
|
Regards,
Rajapandiyan S
Hi,
It´s working.
Thanks.
Hi Roberto,
We are happy to hear that you have achieved your requirement with the solution provided.
Please get back to us if you need further assistance.
Regards,
Rajapandiyan S