Closed JOKaija closed 7 years ago
the setArray wont trigger sorting, have you chacked the array you are passing into the grid?
ps! on booleans and numbers you need go use value converter to keep them from turning into text because that will mess up future sorting and filtering
Converter didn't help (converter copied from your git). Rows will be sorted only after: if I click column "sort uparrow/downarrow".
{colField:"Id", colField:"Id | numberFormatter", colSort:"field:Id;asc:true", colHeaderName:"Id", colType:"number", colWidth:100, colFilter: "field:Id;" , colFilterMenu:"filter:Id",colAddRowAttributes:"readonly"},
Data, what is coming in to client from server is ALWAYS min-id ---> max-id order. The way, how the sql server saves data to table. I do not use/accept reusing deleted record slots in table.
Rechecked data
Yep, as I said. Record with id 79 is the first one on datastream incoming to client...
Yep, as I said. Record with id 79 is the first one on datastream incoming to client...
So the grid isnt the issue, its the data you are getting, or are I missing something?
Grid IS the issue. Grid shows wrong record on first line (Picture above).
k, Ill have a new look at it later today when I get a chance to se if I manage to reproduce it
Rechecked data Yep, as I said. Record with id 79 is the first one on datastream incoming to client...
Before I get a chance to test this later Can you do me a favor and do console.log(yourData[0]) right before and right after setting data to array
console.log(yourData[0])
datasource.setArray(yourData)
console.log(yourData[0])
Not at my computer so cant test, but looking at my code, having a hard time seeing how and why, but maybe Im blind today, happen before 😄
Btw, are you doing any filtering after setting the data ? Because that will mess up order if you havent set any.
I'm doing first filtering instantly after setting data.
Original data order remains same as after setting data/filtering, but order in grid is wrong after first "empty" filtering...
I set only couple filter operators on "initially filtering" like this:
this.ds.query([{attribute:"TargetCondition_s", operator:'*', value:""},{attribute:"TargetAssemblerName", operator:'*', value:""}]);
This was only for testing to get operators ready. But I need to set * operator to every columns at start anyway...
So, the filtering is the bad apple with this scenario. Shouldn't be. Since there is nothing to filter even...
I set only couple filter operators on "initially filtering" like this: this.ds.query([{attribute:"TargetCondition_s", operator:'', value:""},{attribute:"TargetAssemblerName", operator:'', value:""}]);
This is the cause of the issue then, just need to set sort order right after, maybe I should add a de When you do filter in js the result isnt sorted. maybe I should use the key I set in each object as default if no sort order exsist, so filtering always reproduces same order when no column is sorted
@JOKaija
I pushed out a new build When setting the array with "setArray() it will set the internal key as sort order by default when no other sort is set, that way result for a filter will come back in same order thay came in, until user sorts in some other way
Some of these parts will evolve over time in the default datasource (array only) Later I want to create a easy to use with remote data for paging, or caching that tracks the entities so you can define a better schema and have undo options etc, skiped that parts because if you feed the grid with 50 rows and want to created tracking entities it will take a few seconds in slow hardware.
Reopen the issue if this new build did not help you
Now it works. Great!
@JOKaija Info about sorting: Added option to set locleCompare to use, since so many uses english browser settings but need sorting to be able to sort locale language
Sample I used to get it to sort Norwegian (my main language)
this.datasource.setLocaleCompare('nb-NO'); //switch out with you locale if you need something else
More about localCompare here: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
List of codes http://stackoverflow.com/questions/3191664/list-of-all-locales-and-their-short-codes
Picture tells everything.
This is situation, when I open page. So, no sortings done before that...
Look at Id.