This is a migrated thread and some comments may be shown as answers.

[Solved] Problem in Clientside Grid Binding

3 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brijendra Kumar
Top achievements
Rank 1
Brijendra Kumar asked on 07 Aug 2009, 08:25 AM
Dear Sir/Madam,


I have a grid. and I am binding this grid clientside from an javascript Array.
but when i bind this grid again with an empty array then grid is showing records correctly but
items are not being clear.
Rad Grid binding code that i have written is as follows:

var seltestRows = new Array();
seltestRows[0] = result.rows[0];
seltestRows[1] = result.rows[1];

 

var tableView = $find("<%=gvTest.ClientID %>").get_masterTableView();

 

tableView.set_dataSource(seltestRows);

tableView.dataBind();



Does anyone knows please tell me.

Thanks & Regards
Brijendra Pandey


3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 07 Aug 2009, 09:15 AM
Hi Brijendra,

 In order to assign data source for the grid and refresh its state on the client, utilize the set _dataSource(dataSource) and dataBind() methods from its client-side API. Keep in mind that the data source passed as an argument to the set_dataSource method should have JSON signature which can be serialized by a web service or a page method.
More information about client-side binding is available here.

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Brijendra Kumar
Top achievements
Rank 1
answered on 07 Aug 2009, 10:56 AM
Dear Pavlina,

i am using this method to bind grid, following is the code to bind, but when i call Delete_Tests() on a button click then i am first deleting rows from array and then again binding this array, after binding, grid is showing same no of records as in array but after delete action and rebinding grid i again doing a loop of grid items length times then it was showing the previous records, is it rising problem because of using update panel? :


 

function LoadExistingTest() {

 

 

try {

 

arrIndex = 0;

seltestRows = new Array();

 

GetData.GetInquriedTestDetail_N(

OnSuccess_LoadExistingTest);

 

 

return false;

 

}

 

catch (e) {

 

alert(

"Error:- Page -> Test.ascx -> Method -> 'LoadExistingTest' \n Description:- \n" + e.description);

 

 

return false;

 

}

}

 

function OnSuccess_LoadExistingTest(result) {

 

 

try {
for (var i = 0; i < result.rows.length; i++) {

 

 

var row = result.rows[i];

 

seltestRows[arrIndex] = row;

arrIndex++;

}

 

var tableView = $find("<%=gvTest.ClientID %>").get_masterTableView();

 

tableView.set_dataSource(seltestRows);

tableView.dataBind();

return false;

 

}

 

catch (e) {

 

alert(

"Error:- Page -> Test.ascx -> Method -> 'OnSuccess_LoadExistingTest' \n Description:- \n" + e.description);

 

 

return false;

 

}

}


***************
and i have a button to delete records :



function

 

Delete_Tests() {

 

 

try {

 

 

var testCodes = new Array();

 

 

var n = 0;

 

 

var grid = $find("<%=gvTest.ClientID %>").get_masterTableView();

 

 

var cell;

 

 

for (i = 0; i < grid.get_dataItems().length; i++) {

 

cell = grid.get_dataItems()[i]._element.cells[0];

if (cell.childNodes[0].type == "checkbox" && grid.get_dataItems()[i]._element.cells[13].innerText.replace(" ", "") == "") {

 

 

if (cell.childNodes[0].checked == true) {

 

 

var code = grid.get_dataItems()[i]._element.cells[1].innerText;

 

testCodes[n] = code;

n++;

arrIndex--;

 

for (var j = 0; j < seltestRows.length; j++) {

 

 

var row = seltestRows[j];

 

 

if (row.crm_test_test_code_2 == code) {

 

seltestRows.splice(j, 1);

}

}

 

}

}

}

}

GlobalMethods.DeleteTest(testCodes, $get("hdnCustID").value, $get("hdnRefCustomerID").value,

 

$get(

"hdnCallNumber").value, userId_Test, OnSuccess_DeleteTest);
return false;

 

}

 

catch (e) {

 

alert(

"Error:- Page -> Test.ascx -> Method -> 'Delete_Tests' \n Description:- \n" + e.description);

 

 

return false;

 

}

}

 

function OnSuccess_DeleteTest(result) {

 

 

try {
var tableView = $find("<%=gvTest.ClientID %>").get_masterTableView();
tableView.set_dataSource(seltestRows);

 

tableView.dataBind();

 

 

return false;

 

}

 

catch (e) {

 

alert(

"Error:- Page -> Test.ascx -> Method -> 'OnSuccess_DeleteTest' \n Description:- \n" + e.description);

 

 

return false;

 

}

}




Please resolve my prob.

Thanks & Regards
Brijendra Pandey
0
Pavlina
Telerik team
answered on 07 Aug 2009, 02:50 PM
Hi Brijendra,

I went through your code and it looks fine to me. At this point in order to find a quick solution of this matter it will be best if you open a formal support ticket and send us a simple running project (incl. CSS, images, skins, DB backup if needed and so on) demonstrating the problem (and step-by-step instructions on doing so). In that way we can reproduce and pinpoint the problems you're facing on our side and provide a solution.

Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Brijendra Kumar
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Brijendra Kumar
Top achievements
Rank 1
Share this question
or