Categories | Question details Back To List | ||
getUserData() fetching improper data Hi, I am using dhtml xgrid, I trying to fetch global data using getUserData() method, I am getting empty data. The below code I am using: //set global user data function setGlobalUserData(colNullable){ nullableColumns = colNullable.split(","); for (var i=0; i<nullableColumns.length; i++){ mygrid.setUserData("","column_"+i,nullableColumns[i]); } for (var i=0; i<nullableColumns.length; i++){ alert(mygrid.getUserData("","column_"+i)); } } In the above code in second for loop I am able to see the global data using getUserData() function. I am able to see the data in alert messages. But later I am editing some rows and calling a method after clicking SAVE button: Here the code follows: //save the grid values using Data Processor function saveGridData(){ for (var i=0; i<5; i++){ alert(mygrid.getUserData("","column_"+i)); } alert("Changed Rows------>"+mygrid.getChangedRows()); var ids = mygrid.getChangedRows().split(",") for (var i=0; i<ids.length; i++) for (var j=0; j<mygrid.getColumnsNum(); j++){ alert(mygrid.getUserData("","column_"+j)); if(mygrid.getUserData("","column_"+j) == 'N' && (mygrid.cells(ids[i],j).getValue() == null || mygrid.cells(ids[i],j).getValue() == "")){ var columnId = mygrid.getColumnId(j); document.getElementById("divErrors").innerHTML = "A value is required for column "+columnId; return false; } } } In the above code I am getting global data as empty in alert messages. In all alert messages the data is empty. Can u please help me to solve the above problem? /Thanks Raj Answer posted by Support on May 16, 2008 07:55 In which moment setGlobalUserData function called? If it was called before grid was initialized - the old userdata may be lost. Each time when grid (re)initialized - old userdata values erased ( after grid.init() or after loading configuration from XML ) Answer posted by Raj on May 21, 2008 02:45 Hi, First I was called before grid initialized, but after seeing your answer I called the setGlobalUserData () method after grid initialized, But I am getting the same result.. Actually I am getting the grid initialization(setting the headers and levels,,etc) code before loading the grid and calling grid.load() function. So I am setting the global data at before loading the grid. Please see my code let me know the cause for issue.... Code: // The heade and other values I am fetching dynamically header=header+pcontArray[0]; if(typeof(mygrid) == "undefined"){ } Please help me this regard and let me know I am doing any thing wrong.... /Raj
Answer posted by Support on May 21, 2008 06:30 The code is correct , and must not cause any issues Please check sample, which was sent to your email, it uses similar approach in grid iniitialization and all works correctly. |