Hello,
How comes the order of the select filter?
Is there a way of infuence it?
My Problem looks like this:
1
2
3
4
46
47
5
50
…
But it should be:
1
2
3
4
5
6
7
8
9
10
11
12
13
…
Hello,
How comes the order of the select filter?
Is there a way of infuence it?
My Problem looks like this:
1
2
3
4
46
47
5
50
…
But it should be:
1
2
3
4
5
6
7
8
9
10
11
12
13
…
You can control values at select filter with “onCollectValues” event. Please find more information here docs.dhtmlx.com/doku.php?id=dhtm … lectvalues
is there a sample somewhere?
Because i dont know what to do with
grid.attachEvent("onCollectValues", function(index){
if (index == 2)
return ["one","two","three"]; //options for select filter
else
return true; //default processing
});
I found out that index is the column. But where is my data?
Update:
can I request the information the grid got already and sort it my way?
Cause this way takes so much power/time
mygrid.attachEvent("onCollectValues", function(index){
if (index == 0){
datas = mygrid.getAllItemIds();
mySplitResult = datas.split(",");
for(i = 0; i < mySplitResult.length; i++){
datas2[] = mygrid.cells(mySplitResult[i],index).getValue();
}
return [datas2];
}else {
return true; //default processing
}
There is no fastest way to get values of all rows in grid.
If you have a lot of rows in grid, you can implement dynamic loading using dhtmlxConnector, use #conntector_select_filter in the header. In such case you will be able to fill such filter with OptionsConnector. You can fetch necessary options on the server side and pass it to the client side to fill filter in the header. Please find more information here docs.dhtmlx.com/doku.php?id=dhtmlxconnector:toc
docs.dhtmlx.com/doku.php?id=dhtm … iltering&s[]=OptionsConnector
This seems like a bug to me… we have properly set the sort type for the 1st column to “int”:
grid.setColSorting(“int,int,str,date,str,str”);
Yet when setting the filter…
grid.attachHeader("#select_filter, ,#select_filter, ,#select_filter,#text_filter");
The 1st column is sorted as if it were alphabetic and not numeric.
I tried using onCollectValues event, but this is a very awkward workaround and for me it is not even working (I simply tried setting hard coded values but they are not showing up… it is still defaulting):
grid.attachEvent(“onCollectValues”, function(index){
if (index == 0) {
return [133,132]; //Doesn’t work
//return [“a”, “b”, “c”]; // This doesn’t work either
//return [“one”,“two”,“three”]; //nor does this…
} else {
return true; //default processing
}
});
It seems that the right fix would be for the filtering to honor the sort type specified in setColSorting.
Unfortunately we cannot reproduce this issue locally. Please provide us a completed demo so we can reproduce an error.
http://docs.dhtmlx.com/doku.php?id=others:how_to_create_the_completed_demo
I took the simple example under grid/filtering → 06_pro_search and simply added a #select_filter to the first column (source and screenshot attached).
mygrid.attachHeader("#select_filter,#text_search,#select_filter, ,#cspan,#cspan");
You can see from screen shot that it sorts like this:
100
1000
101
etc…
I’m saying that since the first column has a sort type of “int” shouldn’t the #select_filter be able to sort the list properly?
mygrid.setColSorting(“int,str,str,int,str,str”)
sortproblem.zip (76.2 KB)
I’m saying that since the first column has a sort type of “int” shouldn’t the #select_filter be able to sort the list properly?
No, “int” sorting type affects only on rows sorting, not on options sorting in #select_filter
OK, well I wrote the following sort routine and it works properly (I can see the values are properly sorted), but the drop down filter still has the same original values. I even tried hard coding it but it seems to be ignoring the result I’m passing back and defaulting.
What am I doing wrong?
return ["one","two","three"]; //options for select filter
Here is the onCollectValues event handler:
ruleHistoryGrid.attachEvent("onCollectValues", function(index){
// Keep deployment id filter drop-down sorted numerically
// index==0 is deployment id column
if (index == 0) {
try {
unsortedIdx = ruleHistoryGrid.getAllItemIds();
mySplitResult = unsortedIdx.split(",");
var unsortedData = new Array();
for (i=0; i<mySplitResult.length; i++) {
cellValue = ruleHistoryGrid.cells(mySplitResult[i],index).getValue();
if (cellValue != '') {
unsortedData.push(parseInt(cellValue));
}
}
return unsortedData.sort(sortNumber);
} catch (e) { alert(e); return true; }
} else {
return true; //default processing
}
});
function sortNumber(a,b) {
return a - b;
}
Check if you returning false from “onCollectValues” event handler to disable default processing
No, if index is correct it returns the result:
return unsortedData.sort(sortNumber);
otherwise it returns true (see source from prior post)…
Can you please provide complete demo where we can reproduce it? docs.dhtmlx.com/doku.php?id=othe … leted_demo