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

Add column via javascript

1 Answer 18 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prem
Top achievements
Rank 1
Prem asked on 29 Aug 2014, 06:22 AM
Hi,

One of our page uses Radgrid and in client-side wanted to add one more column to the grid. Have been searching the whole site for any ideas or answers but no luck.

Below is the code

<script type="text/javascript">
 
Sys.Application.add_load(function () {

$("#master_DefaultContent_rts_ts1891_s4143_f3987srvgrid_ctl00 thead tr").append("<th>Primary Selection</th>");
$("#master_DefaultContent_rts_ts1891_s4143_f3987srvgrid_ctl00 tr:gt(0)").append("<td><input id='PrimarySelection' type='checkbox' onclick='handleClick(this);' /></td>");

var tableView = $find("<%= master_DefaultContent_rts_ts1891_s4143_f3987srvgrid %>").get_masterTableView();
tableView.rebind();

});

function handleClick(cb) {
var user = $(this).closest("tr").find("td:eq(1)").text();
alert(user);
userIds.splice($.inArray(user, userIds), 1);
if (cb.checked) {
userIds.push(user);
}
}

</script>

Thanks,
Prem

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 29 Aug 2014, 07:12 AM
Hi Prem,

​Creating RadGrid programmatically client-side is not possible. Currently, RadGrid requires its columns to be created on the server side. This is essential for the proper functioning of the control, even though you may bind the grid on the client-side. However you can define its structure on the server and bind it on the client as shown in this example:

http://demos.telerik.com/aspnet-ajax/Grid/Examples/Client/DeclarativeDataBinding/DefaultCS.aspx


Thanks,
Shinu
Tags
Grid
Asked by
Prem
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or