Hi,
I can’t get the custom sorting to work. It’s probably quite simple, but I can’t find it.
Here’s the code for the header in the XML:
<?xml version='1.0'?>
Klant
AGM
CBH
CGP
CIT
COM
EMX
HAC
KOE
MOE
VGO
[snip]more header[/snip]
[snip]data[/snip]
And here’s the JS init-part:
mygrid= new dhtmlXGridObject(‘container_overzicht’);
mygrid.selMultiRows = true;
mygrid.setImagePath(“dhtmlx/dhtmlxGrid/imgs/”);
mygrid.attachEvent(“onBeforeSorting”,function(cInd,type,direction){
alert('Kolom: ‘+cInd+’, type: ‘+type+’, dir: '+direction);
});
mygrid.enableDragAndDrop(false);
mygrid.init();
mygrid.setSkin(“dhx_black”);
mygrid.loadXML(“ajax/taken/gettaken.php”+params);
mygrid.attachEvent(“onEditCell”, DoOnEditCell);
And the function custom_1 (meant to be sorting the column):
function custom_1(a,b,ord,a_id,b_id){
a=mygrid2.cells(a_id,0).getText();
b=mygrid2.cells(b_id,0).getText();
return ord==“asc”?(a>b?1:-1):(a>b?-1:1);
}
The event OnBeforeSorting I added only for debugging purposes. What struck me as odd was that the alert says that the column type is custum_1… A clue?
Meanwhile, sorting works for all the other columns, but not the first one. Help would be appreciated.
The event OnBeforeSorting I added only for debugging purposes. What struck me as odd was that the alert says that the column type is custum_1… A clue?
“type” argument contain type of the sorting - str, int, date,na or name of the custom sorting function.
>>Meanwhile, sorting works for all the other columns, but not the first on
"onBeforeSorting" event is blockable (if custom code, attached to event, returns value different from true - sorting operation will be blocked).
As you can see, the onBeforeSorting returns true always. But, to be sure, I removed that part, as it wasn’t necessary. But it changes nothing, sorting still doesn’t work.
Is there something else I should check? Do you need more information?
Hello
sorry for delay. Custom sorting functionality works only in PRO edition. If the issue occurs with PRO edition, please provide the sample to support@dhtmlx.com to recreate it