1

How would you modify the knockout.js simpleGrid plug-in to support column sorting?

I have got the following code: http://jsfiddle.net/NaveenVelaga/QSRBR/9/

Michael Haren
  • 105,752
  • 40
  • 168
  • 205
Naveen Velaga
  • 648
  • 1
  • 11
  • 22

2 Answers2

3

Use KnockoutSimpleSortableGrid found at https://shiljopaulson.github.io/Knockout.simpleSortableGrid/ and it contains samples in it

Shiljo Paulson
  • 518
  • 7
  • 17
  • This is great. I'm going to switch to using this. Has anyone looked into refreshing columns data binding, so that these name/labels could be altered after initial creation of the grid view? I'd like to see the column labels be observable. – truedat101 Oct 05 '18 at 17:31
  • 1
    that can be done by changing the columns variable to ko.observableArray please refer the https://github.com/shiljopaulson/Knockout.simpleSortableGrid/blob/master/sample02.html – Shiljo Paulson Oct 16 '18 at 15:06
2

I have had a fiddle with the supplied code.

I have modified the simpleGrid code to expect a sorting function in the column data. This way we can wire up the template to sort on click via the supplied function.

http://jsfiddle.net/QSRBR/39/

This is a simple solution which needs to be expanded to include bi directional sorting logic (second click sorts in reverse direction)

Andrew Harry
  • 13,773
  • 18
  • 67
  • 102