Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by mnicolas80 on Nov 18, 2008 16:52
open dhtmlx forum
filtering + xml reloading...

I am using grid with filter functionality. The first time i request dynamic data, the filters(2 Header lists) + results appear correctly!
When i send new paramaters in order to reload data (to the same grid), i get the xml results but the 2 filter cause the following error:

[Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLDivElement.appendChild]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: [ MY JS URL ] :: anonymous :: line 26" data: no] ...

//-----------------------MY CODE
mygrid.init();
mygrid.loadXML("ajax/xml.php?uid="+(new Date()).valueOf() + "&[ MY PARAMETERS],function(){
mygrid.attachHeader("<div id='list1_flt'></div>,<div id='list2_flt'></div>,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan");
var list1Flt = document.getElementById("list1_flt").appendChild(document.getElementById("list1_flt_box").childNodes[0]);
populateSelectWithList1(list1Flt);
var list2Flt = document.getElementById("list2_flt").appendChild(document.getElementById("list2_flt_box").childNodes[0]);
populateSelectWithList2(list2Flt);
mygrid.setSizes();
//-----------------------MY CODE

It seems like the grid does not re-attach the filters...
Any idea?
Answer posted by Support on Nov 19, 2008 03:05
Not quite sure, but I think , that the problem is in "list1_flt_box" element, which can't be found after grid reloading. 

The order of actions are next

- grid initialized
- filter boxes attached to the grid
....
- grid cleared ( filter boxes fully removed from DOM )
- new data loaded
- code failed becuase it can't find filter box ( list1_flt_box) element in DOM ( it was removed during grid clearing ) 
Answer posted by mnicolas80 on Nov 19, 2008 15:22
Ok, but it is really strange... I mean that filters work only the first time i create the grid. When i re-create it using different post parameters for php/xml generator, the filters disappear?!
Also i have not any code that destructs the filters. What i am doing is to re-init the grid (as the first time, using the same function) and then i load the xml with different parameters.
Is there any way to check (the second time) if the grid exists, then destroy it and re-create it, instead of just re-creating it? In this way maybe it clears everything...
Answer posted by Support on Nov 20, 2008 02:29
>>Also i have not any code that destructs the filters.
Whe your reloading grid with new configuration,  old headers removed, which includes filters inserted in headers.

>>and then i load the xml with different parameters.
If you will reload only data part of XML - it will work correctly, but it seems that you are reloading XML with <head> section which result in full grid reset. 

>>Is there any way to check (the second time) if the grid exists, then destroy it and re-create it
if (window.mygrid){  //mygrid.exists
     mygrid.destructor();
     call_init_code();
}
Answer posted by mnicolas80 on Nov 21, 2008 00:45
Is it possible to provide an example that combines both filtering and grouping functionality? Also the specific grid must use the functionality of XML reloading...
Thank you!
Answer posted by Support on Nov 21, 2008 02:24
Requested sample sent by email