grid.sortRows(...) results in TypeError: this.rowsBuffer[i]


I’m building dhtmlXGridObject and loading data from XML. When page got refreshed by action of user and a row is now missing in new XML I got alert TypeError: this.rowsBuffer[i] has no properties. No need to say that the sorting will not take place :frowning:

Row ids remain the same after refresh. Only the deleted row is missing.


var grid = new dhtmlXGridObject(‘someId’);

var header = ‘col1, col2’;






var xmlContent = ‘someXML’;


grid.sortRows(0, “str”, “asc”); // error occurred here

grid.setSortImgState(true, 0, “asc”);

Thanks for help


This issue occurs because of not all rows was rendered. You should call sortRows method only after all rows was loaded. To detect if all rows was loaded you can use “onXLE” event (availible at PRO version) or 2nd parameter of load() method. As you are using parse method the only way to call command after grid was loaded is to use “onXLE” event:


grid.sortRows(0, “str”, “asc”); // error occurred here
grid.setSortImgState(true, 0, “asc”);


I tried what you suggested before in somewhat different way and now again your code exactly but i still got the same error :frowning:

My guess is that for some reason the grid is still trying to sort the
row it does not have. What leads me to this is the fact that both your
and mine solution works fine when I add row or refresh the page without
removing any row.

FYI: We are using dhtmlxSuite_2009Rel1_pro_90226 this version

Do feel free to contact me for more information if you need them.


Could you please provide us sample where we can reproduce this issue? You can send it directly to the


When I was preparing some page to send you I found the problem …
The XML that I was sending from server did not have its total_count decreased :frowning:
<rows pos=“0” total_count=“203”>…

Now everything works fine :wink:
Thank you for your effort.