Set the default sort column in SlickGrid

I am using SlickGrid with a DataView and I am trying to set the default sort column on my table. Is there a way to call sorting or set a parameter to sort the column at startup?

+6
source share
3 answers

In the latest version, you can do this:

grid.setSortColumn("myColId",true); //columnId, ascending 

You can also set multiple using setSortColumn * s *

+9
source

See my solution here. This will apply column sorting initially without using Dataview.

Slickgrid Sort Call

I think he does what you want.

Btw since you are using Dataview. You can also try. But I personally did not.

  dataview.reSort() 
+1
source

I had an interesting idea that worked, and it was just to enable sorting of the headers of several columns (example-multi-column-sort.html), and then after loading the grid, simulate a click () in the header I would like to sort when the grid first appeared ("time" is the name of my column that I sorted). The column heading identifier is calculated similarly to the identifier for the root div of the grid (at least at the moment: 0)):

  var gridId = $('#myGrid').attr("class"); gridId = '#'+gridId.replace(" ui-widget","")+'time'; $(gridId).click(); 

The user can then click on any other column headings that they want, but I just clicked them first.

0
source

Source: https://habr.com/ru/post/911211/


All Articles