Click here to Skip to main content
15,907,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm creating a new row in string format like s="
HTML
<tr><td></td></tr>
"
and returning it by webmethod to ajax.
ajax({
type: "POST",
url: "notification.aspx/ReturnTableRow",
data: JSON.stringify({ maxidfetched: maxid, empid: empid }),
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function () {

},
success: function (response) {
if (response.d.trim() != "") {
tbl.prepend(response.d);


}

},
failure: function (response) {
//alert(response.d);
}

});

response.d is returned row element as string.
I have tbl which is initialized as datatable and row will be added to it.
but after adding row to tbl how to reinitialize it?
on form load if I initialize tbl then datatable structure is created.
but after prepending the row element the structure destroyed.

There are many helps in internet to add rows as
rows.add(
[]);
but it just add cells and create a new row.It doesn't have flexibility.
I I want to write a tr element then how to do it?
Posted
Updated 21-Feb-15 8:56am
v6

1 solution

JavaScript
tbl.prepend($(response.d));

try the above code instead of tbl.prepend(response.d), because the "prepend()" only accepts elements as parameter.
 
Share this answer
 
Comments
souvikcode 25-Feb-15 12:02pm    
nothing change.I asked how to recreate the datatable.There is no problem with prepending row.Just want to know after prepending row how to create datatable because there is problem with re initialization after adding row.
Solai Raja 26-Feb-15 0:09am    
re initiate Data table, in the sense what, do mean C# Data table or HTML table?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900