Strange bug in Tree Table sorting.

With this, the FIRST column (‘a’) sorts properly only. Second one’s sort behaviour is very strange (only 2-3 rows move around when sorted. They get exchanged within themselves. Always the same rows. (My data is being loaded on button press from a POST via AJAX.

As you can see, these is IDENTICAL columns, except a slight change in the ID and in the header. newop[1] contains an array of strings [“A1”,“A2”,…].

(NOTE: For my use case, length of newop[1] is 1, so a single iteration within the loop)

http://pastie.org/9450620

Here’s the strange part. If I remove the newop[1][i] from the ID, (rest everything same); the sort starts that same weird behavior for both columns!

http://pastie.org/9450621

If I replace newop[1][i] with some other variable, again both stop working.

I’ve spend HOURS trying to debug this, but I think it’s safe to conclude that this is a bug. Or am I missing something?

Change sorting type to the “text” it will fix issue ( I hope so )

While sorting and filtering datatable do use the raw value, not the result of template.
So in you case it will sort by obj._ds and obj._ds2, and not by visible text (result of template function ). With “text” sorting mode, component will sort rows by visible text ( template function ) for the column in question.

Okay I skipped that for now since it was getting a bit too complicated.
According to http://docs.webix.com/datatable__templates.html,

“You can use both template and format attributes for the same column. In such case column will format data first, and will use it in template after that.”
http://pastie.org/9452065
So yeah, my data is being formatted well with the format function, but if I use any template after that, the formatting disappears and I’m left with the template being processed on the unformatted text.

So my columns look like ‘$ 442234’ instead of ‘$ 442,234’ which I need.

In case I’m going wrong, this is what I need:

  1. I need the SORT to work on normal number values.

  2. I need to apply basic templates (like say, the currency symbol above, or some other computed value).

Any easy way to make that work? If the template function was actually processing on the formatted value, then it would be ideal.

You can use
http://webix.com/snippet/d0ec0b9f

or
http://webix.com/snippet/9e2eee04