Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ramesh Manian on Apr 15, 2008 22:11
open dhtmlx forum
Grid Values loading through Javascript

Hi,
I am trying to load the values in to the grid using Javascript as follows.

function PopulateDataInGrid(arrValues)
{
if (!(arrValues=='null'))
{
var r;
var valuesarr;
rowsarr = arrValues.split(",");

if (rowsarr.length!=0)
    {
    for (var i=0;i<=rowsarr.length-2;i++)
            {    
            valuesarr = rowsarr[i].split("|");
            
                if (valuesarr[0].length==0)
                    {
                    }
                else
                    {
                        mygrid.cells(valuesarr[0],valuesarr[1]).setValue(valuesarr[2]);
                    }
            }
        
    }
}

}

The values are getting set and doesnt get any errors. but the problem is THE VALUES ARE NOT GETTING DISPLAYED. IT SHOWS A BLANK GRID EVEN AFTER THE VALUES ARE SET. when i use alert(), it alerts the values correctly. pls help me in fixing this problem
Answer posted by Support on Apr 16, 2008 02:46
The grid.cells(i,j).setValue(val)  command change the content of HTML cell directly, there is no way  to call setValue and not update HTML of related cell.
Please be sure that in described scenario
    valuesarr[0] - correct row ID
    valuesarr[1] - correct column index

If row ID or column index incorrect - this will cause inner error, and new value will not be set
Answer posted on Apr 16, 2008 03:04

I am able to get the values displayed through alert() function. but in the grid these values are not getting displayed(updated).

i.e, alert(mygrid.cells(valuesarr[0],valuesarr[1]).getValue()); displays the value but in the grid, value is not displayed.

 Same is the case, if i try to set the cell type. On giving the alert function, the new cell type is shown but in the grid its not getting effected.

 

Answer posted by Support on Apr 16, 2008 04:22
It is impossible, because getValue returns data from rendered HTML, please be sure that used rowID refers to the same visible row
Also please be sure that you are using unique IDs for each row in grid, in other case different errors include mentioned one may occurs.
Answer posted by RAMESH MANIAN on Apr 16, 2008 05:01

Still i am getting the same problem. pls assist me with the sample code

hereby i am attaching the xml file as well as the coding  (in a single word document)

pls help me

 

 

Attachments (1)
Help.doc32.77 Kb
Answer posted by Support on Apr 16, 2008 09:39
In your code the next code used

        mygrid.loadXML("G_"+ page +".xml");
        document.getElementById("hid_page").value=page;
        PopulateDataInGrid(sesvalue); // Populate DATA in the grid with the session value


The loadXML command is async, so the PopulateDataInGrid function can be executed before data and configuration loaded from xml.

You can update code in next way

    mygrid.loadXML("G_"+ page +".xml",function(){
        PopulateDataInGrid(sesvalue); // Populate DATA in the grid with the session value
    });