Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Emilie Meunier on Mar 10, 2009 07:33
open dhtmlx forum
filter header dhtmlxgrid

Hi,

I want to put filters in the header and it gives me an error when I loading my page… Error line 837: _locator is null or not an object...
I would like to know how to fill the combo box of a filter?

Here is the code:

<link rel="STYLESHEET" type="text/css" href="../../../class/dhtmlxgrid/codebase/dhtmlxgrid.css">
<script src="../../../class/dhtmlxgrid/codebase/dhtmlxcommon.js"></script>
<script src="../../../class/dhtmlxgrid/codebase/dhtmlxgrid.js"></script>
<script src="../../../class/dhtmlxgrid/codebase/dhtmlxgridcell.js"></script>
<script src="../../../class/dhtmlxgrid/codebase/ext/dhtmlxgrid_start.js"></script>
<script src="../../../class/dhtmlxgrid/codebase/ext/dhtmlxgrid_srnd.js"></script>
<script src="../../../class/dhtmlxgrid/codebase/ext/dhtmlxgrid_mcol.js"></script>
<script src="../../../class/dhtmlxgrid/codebase/ext/dhtmlxgrid_group.js"></script>
<script src="../../../class/dhtmlxgrid/codebase/ext/dhtmlxgrid_filter.js"></script>


<div id="products_grid" style="width:100%;height:400px;"></div>
<div>Records found: <span id="recfound"></span></div>

var gridQString = "";
var mygrid = new dhtmlXGridObject('products_grid');

mygrid.setImagePath("../../../class/dhtmlxgrid/codebase/imgs/");
mygrid.setHeader("User Name,Courriel,Service");
mygrid.attachHeader("#text_filter,#text_filter,#select_filter");
mygrid.setInitWidths("200,200,300");

mygrid.setColAlign("left,left,right");
mygrid.setColTypes("ed,ed,ed");
mygrid.setColSorting("server,server,server");
mygrid.enableMultiline(true)
mygrid.init();
mygrid.setSkin("modern");
mygrid.enableSmartRendering(true);

gridQString = "getGridRecords.asp";//save query string to global variable (see step 5 for details)
mygrid.loadXML(gridQString);

Answer posted by Support on Mar 11, 2009 02:38
Such error can occur if you are using smart rendering with dyn. loading 
If not all data loaded at once, grid not able to use client side filtering and sorting ( because it need to have all data available for such operation ) 
Answer posted by Emilie Meunier on Mar 11, 2009 05:36
Yes I used smart rendering with dyn. loading... So what is the solution?
Answer posted by dhxSupport on Mar 11, 2009 06:18
If you are using smart rendering with dyn.loading you can use server side sorting
Answer posted by emilie on Mar 11, 2009 06:31

I already used the server side sorting but the problem is the function attachheader... Do you have a simple with smart rendering and filter header? This is all my code:

var gridQString = "";

var mygrid = new dhtmlXGridObject('products_grid');

mygrid.setImagePath("../../../class/dhtmlxgrid/codebase/imgs/");

mygrid.setHeader("User Name,Courriel,Service");

mygrid.attachHeader("#text_filter,#text_filter,#select_filter");

mygrid.setInitWidths("30,200,300,400");

mygrid.setColAlign("center,left,left,right");

mygrid.setColTypes("img,ed,ed,ed");

mygrid.setColSorting("int,str,str,str");

mygrid.setColumnIds("0,-1,1,2");

//mygrid.enableColumnMove(true);

mygrid.init();

mygrid.setSkin("modern");

mygrid.enableSmartRendering(true);

gridQString = "getGridRecords.asp";//save query string to global variable (see step 5 for details)

mygrid.loadXML(gridQString);

dhtmlxError.catchError("ALL", myErrorHandler);

mygrid.attachEvent("onBeforeSorting",sortGridOnServer);

function myErrorHandler(type, desc, erData)

{

return false;

}

 

function sortGridOnServer(ind,gridObj,direct)

{

mygrid.clearAll();

mygrid.loadXML(gridQString+(gridQString.indexOf("?")>=0?"&":"?")+"orderby="+mygrid.getColumnId(ind)+"&direct="+direct);

mygrid.setSortImgState(true,ind,direct);

return false;

}

Answer posted by dhxSupport on Mar 11, 2009 07:00
You can see example here http://dhtmlx.com/docs/products/dhtmlxGrid/samples/filtering/pro_filter_srnd.html (this functionality is avalible at PRO version only)
Answer posted by emilie on Mar 11, 2009 10:11
Do you have a sample with smart rendering, filter header, server side sorting and dynamic loading? Because this is what I have and I get the error when I load the page... If I put in commentary this part of code :

mygrid.attachEvent("onBeforeSorting",sortGridOnServer);

, i don't get the error anymore but I cannot sort...

Answer posted by emilie on Mar 11, 2009 11:12
ok, finaly I solved my problem. Thanks for your help.