Sunday, 11 August 2013

jquery clone function gridview

jquery clone function gridview

hi guys need a help here below is my code
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Customers");
var row = $("[id*=gvCustomers] tr:last-child").clone(true);
$("[id*=gvCustomers] tr").not($("[id*=gvCustomers]
tr:first-child")).remove();
$.each(customers, function () {
var customer = $(this);
$("td", row).eq(0).html($(this).find("fname").text());
$("td", row).eq(1).html($(this).find("mname").text());
$("td", row).eq(2).html($(this).find("lname").text());
$("td", row).eq(3).html($(this).find("qualifier").text());
$("td", row).eq(4).html($(this).find("alias").text());
$("td", row).eq(5).html('<a class=1ref
href=Default.aspx?id=' + $(this).find("pid").text() + '><i
class=icon-zoom-in icon-white></i>View</a>' + '&nbsp;' +
'<a class=2ref href=Default.aspx?id=' +
$(this).find("pid").text() + '><i class=icon-edit
icon-white></i>Edit</a>');
$("[id*=gvCustomers]").append(row);
row = $("[id*=gvCustomers] tr:last-child").clone(true);
});
var pager = xml.find("Pager");
$(".Pager").ASPSnippets_Pager({
ActiveCssClass: "current",
PagerCssClass: "pager",
PageIndex: parseInt(pager.find("PageIndex").text()),
PageSize: parseInt(pager.find("PageSize").text()),
RecordCount: parseInt(pager.find("RecordCount").text())
});
now i dont have any problem displaying data when the grid has a previous
displayed data. my question is when the gridview doesn't have any data the
clone function actually clones the column header not the child rows.
now i tried counting the rows of the grid before cloning to avoid cloning
the column header but the result is it wont display the data.
any suggestion would be helpful thank you

No comments:

Post a Comment