Reputation: 1563
Im using ui-grid to load my data set. Here is my requirment;
step 01: I want to load dataset_01 (scope.gridOptions.data = res_01;
).
step 02: I want to sort by First Name (Click by firstname
column).
step 03: Click an external button and Reload ui-grid with an another data set (scope.gridOptions.data = res_02;
).
Here is my result:
I dont want sort by First Name
here for second dataset.
I want data without sorting. How can I do it ?
Expected result:
So I want to reload second data set without sorting (Means I want to remove first sorting before load second data set). how can I reset my ui-grid before load next data set (scope.gridOptions.data = res_01;
).
How can I do it ?
Thank you. :)
Upvotes: 1
Views: 2760
Reputation: 530
example
$scope.gridOptions = {
useExternalPagination: true,
useExternalSorting: false,
enableFiltering: false,
enableSorting: true,
enableRowSelection: false,
enableSelectAll: false,
enableGridMenu: true,
enableFullRowSelection: false,
enableRowSelection: false,
enableRowHeaderSelection: false,
paginationPageSize: 10,
enablePaginationControls: false,
enableRowHashing: false,
paginationCurrentPage:1,
columnDefs: [
{ name: "FristName", displayName: "Frist Name", width: '6%', sort: { direction: undefined } },
]
};
after that you can remove the sorting where you want using below code
$scope.RemoveSorting = function ()
{
$scope.gridOptions.columnDefs.forEach(function (d) {
d.sort.direction = undefined;
})
}
Upvotes: 0
Reputation: 734
You can set the sort
property of your columnDefs
to:
sort: {
direction: undefined,
}
and call for grid refresh using $sope.gridApi.core.refresh()
after. This should re-render the whole grid and get rid of the sorting.
Upvotes: 3
Reputation: 13
Visit this page: http://ui-grid.info/docs/#/api/ui.grid.core.api:PublicApi
After having instantiated your gridApi, you can just call:
$scope.gridApi.core.refresh();
Hope that helps! :)
Upvotes: 0