I was wondering if it is possible to bind a grid client-side when it has been generated on the server with the use of GridTemplateColumns and ItemTemplateColumns. This is currently not working for me. Am I missing something or is this functionality simply not supported? Is the grid binding but not updating on the page? When I try to do the client-side binding on a grid that has simply been dropped on the page it does work.
Thanks very much in advance!
This is my code:
var weeks = null
var tableView = null;
function pageLoad(sender, args)
{
$.ajax({
type: "POST",
url: "test.aspx/GetData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: refreshControls,
fail: onFail
});
}
function refreshControls(result)
{
weeks = eval(result.d);
}
function GridCreated(sender, eventArgs) {
if (sender.Control.id == "<%= Grid1.ClientID %>")
tableView = $find("<%= Grid1.ClientID %>").get_masterTableView();
}
function ReDrawGrid()
{
weeks[0].amount = 82;
tableView.set_dataSource(weeks);
tableView.dataBind();
}
On Server
private void DefineGridStructure(int columnCount)
{
Grid1.AutoGenerateColumns = false;
Grid1.AllowSorting = false;
Grid1.AllowPaging = false;
Grid1.GridLines = GridLines.None;
Grid1.NeedDataSource += new GridNeedDataSourceEventHandler(doiGrid_NeedDataSource);
Grid1.ClientSettings.ClientEvents.OnGridCreated = "GridCreated";
//scrolling
Grid1.ClientSettings.Scrolling.AllowScroll = true;
Grid1.ClientSettings.Scrolling.UseStaticHeaders = true;
//Master Table
Grid1.MasterTableView.TableLayout = GridTableLayout.Fixed;
Grid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
Grid1.Width = Unit.Pixel(columnCount * 88);
Grid1.Height = Unit.Pixel(126);
//Columns
GridTemplateColumn templateColumn = new GridTemplateColumn();
templateColumn.AllowFiltering = false;
templateColumn.ShowFilterIcon = false;
templateColumn.HeaderTemplate = new HeaderTemplate(columnCount);
templateColumn.ItemTemplate = new ItemTemplate(columnCount);
Grid1.MasterTableView.Columns.Add(templateColumn);
}