Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Madhu on Aug 11, 2008 07:13
open dhtmlx forum
Invalid Argument

Hi,

I am using dhtmlx v1.5 build 80319.
I am facing a js error (Invalid Argument) while dynamically inserting a column to a dhtmlx grid.

For your ref, the piece of code is as follows,
------------------------------------------------------

mygrid = new dhtmlXGridObject(gridTarget);                    
mygrid.imgURL = "<%=appName%>/images/";
mygrid.setHeader('Pay Category,Total Hrs,Total Cost');
mygrid.attachHeader('#rspan,#rspan,#rspan');
mygrid.setInitWidthsP('*,5,5');                    
                        mygrid.setSkin("light");                                                                         
mygrid.setColAlign('left,right,right');
mygrid.setColSorting('na,na,na');
mygrid.setColTypes('ro,ro,ro');
mygrid.enableAutoHeigth(true);
mygrid.enableColumnAutoSize(false);
mygrid.init();
                        
mygrid.insertColumn(mygrid_<%=unitIdKey%>.getColumnsNum()+1,'Dept Name','ro','10','na','right','right',false,'white');

------------------------------------------------

Can you pls help me fix this

Thank you in advance,

Madhu
Answer posted by Support on Aug 11, 2008 08:24
You are using "right" value for "vertical align" parameter, which is not correct value ( cause error in IE ) 
replace it with empty string or correct  value ( top, bottom, etc. )
Answer posted by Madhu on Aug 11, 2008 08:35
Hi,

I have changed the vAlign param to 'top' and also to '' .
Still it is showing the error. (Invalid Argument)

                        mygrid_<%=unitIdKey%> = new dhtmlXGridObject(gridTarget);                   
                        mygrid_<%=unitIdKey%>.imgURL = "<%=appName%>/images/";
                        mygrid_<%=unitIdKey%>.setHeader('Pay Category,Total Hrs,Total Cost');
                        mygrid_<%=unitIdKey%>.attachHeader('#rspan,#rspan,#rspan');
                        mygrid_<%=unitIdKey%>.setInitWidthsP('*,5,5');                   
                        mygrid_<%=unitIdKey%>.setSkin("light");                                                                              
                        mygrid_<%=unitIdKey%>.setColAlign('left,right,right');
                        mygrid_<%=unitIdKey%>.setColSorting('na,na,na');
                        mygrid_<%=unitIdKey%>.setColTypes('ro,ro,ro');
                        mygrid_<%=unitIdKey%>.enableAutoHeigth(true);
                        mygrid_<%=unitIdKey%>.enableColumnAutoSize(false);
                        mygrid_<%=unitIdKey%>.init();                
      
                        mygrid_<%=unitIdKey%>.insertColumn(mygrid_<%=unitIdKey%>.getColumnsNum()+1,'Dept Name','ro','10','na','right','top',false,'white');

The modified code is given above, with the last line of code changed.
Here I am using mygrid_<%=unitIdKey%>, as I have to create multiple grids based on the different keys.

Awaiting your reply,

Thanks,
Madhu
Answer posted by Support on Aug 11, 2008 09:28

The same code works correctly in local tests - please check sample ( sent by email )

If problem still occurs for you - try to use dhtmlxgrid_mcol.js from sample. 

Answer posted by Madhu on Aug 11, 2008 10:16
Hi,

I have tried it, but its giving the same error.

The below piece of code works fine in Firefox. Also when I create a new jsp and add this code this is perfectly working fine(both in IE and Firefox).
But in my application's jsp page which has other grids in the same page though with different grid names, this error is coming again and again. (with Firefox no problem)
I have included
This is the piece of code.

<head>
<link rel="stylesheet" type="text/css" href="<c:url value='/css/dhtmlXGrid.css'/>">
<link rel="stylesheet" type="text/css" href="<c:url value='/css/dhtmlXGrid_skins.css'/>">

<script src="<c:url value='/scripts/dhtmlx/dhtmlxGrid/codebase/dhtmlxcommon.js'/>"></script>
<script src="<c:url value='/scripts/dhtmlx/dhtmlxGrid/codebase/dhtmlxgrid.js'/>"></script>
<script src="<c:url value='/scripts/dhtmlx/dhtmlxGrid/codebase/dhtmlxgridcell.js'/>"></script>
<script src="<c:url value='/scripts/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_filter.js'/>"></script>
<script src="<c:url value='/scripts/scbr/gridtree/dhtmlXGrid_form.js'/>"></script>
<script src="<c:url value='/scripts/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_mcol.js'/>"></script>
</head>

body......

<td>
            <div id="div_pay_cat"></div>                   
                    <script>
                        var gridTarget = "div_pay_cat";                           
                        mygridnew = new dhtmlXGridObject(gridTarget);                   
                        mygridnew.imgURL = "<%=appName%>/images/";
                        mygridnew.setHeader('Pay Category,Total Hrs,Total Cost');
                       
                        mygridnew.setInitWidthsP('10,5,5');                   
                        mygridnew.setSkin("light");                                                                              
                        mygridnew.setColAlign('left,right,right');
                        mygridnew.setColSorting('na,na,na');
                        mygridnew.setColTypes('ro,ro,ro');
                        mygridnew.enableAutoHeigth(true);
                        mygridnew.enableColumnAutoSize(false);
                        mygridnew.init();
                                                   
                        mygridnew.insertColumn(mygridnew.getColumnsNum()+1,'Dept Name','ro','10','na','right','top',false,'white');                       
                        mygridnew.addRow(1,['madhu','madhu1','madhu2','madhu3'],1);                       
                    </script>
        </td>

Please help me thru this....

Thanx in advance,

With regards,

Madhu
Attachments (1)
Answer posted by Support on Aug 12, 2008 02:47

In case of IE problem can be caused by complex HTML layout. Cells in such layout will have height settings only when table tag already closed, untill that time cell have not height, and because of that grid can't be init. Calling insertColumn command against such collumn cause an error.

You can 
a) run init code from onload handler
b) move js part of code below table tag