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

Error when trying to select all from the first page of a grid.

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 07 Sep 2011, 09:30 PM
Hello,

I have searched and I cannot seem to find a solution to my issue, when creating a RadGrid programmatically (is that even a word?) everything seems to work fine except that something is wrong with the first page in the pager, I have a GridClientSelectColumn and when I try and use the select all box in the header I get this error:
Error: Unable to get value of the property '_selectAllRows': object is null or undefined

The strange thing is I can select things through the column itself and I can navigate the pager and select all from the other pages in the grid, when I do this something still messes up though. When I navigate away from the first page of the pager the grid is unable to load that first page again, nothing happens when you click on the first page.

If I build the grid on the front end everything seems to work fine.

The code is:

private RadGrid DefineGridStructure()
{
 RadGrid grid = new RadGrid();
 grid.ID = "OptOutGrid";

 grid.Width = Unit.Percentage(100);
 //grid.Height = Unit.Pixel(400);
 grid.CssClass = "LeftFloat Top15Margin RadGridAutoSize";
 grid.PageSize = 25;
 grid.EnableAjaxSkinRendering = true;
 grid.AllowPaging = true;
 grid.AutoGenerateColumns = false;
 grid.AllowMultiRowSelection = true;

 grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;

 grid.ClientSettings.Selecting.AllowRowSelect = true;
 grid.ClientSettings.Selecting.UseClientSelectColumnOnly = true;
 grid.ClientSettings.Scrolling.AllowScroll = true;
 grid.ClientSettings.Scrolling.UseStaticHeaders = true;
 grid.ClientSettings.Scrolling.SaveScrollPosition = true;

 //grid.MasterTableView.DataKeyNames = new string[] { "PanelistID" };
 grid.MasterTableView.TableLayout = GridTableLayout.Fixed;

 GridBoundColumn col;

 col = new GridBoundColumn();
 col.DataField = "PanelistID";
 col.HeaderText = (string)GetLocalResourceObject("grid_PanelistID");
 col.UniqueName = "PanelistID";
 grid.MasterTableView.Columns.Add(col);

 col = new GridBoundColumn();
 col.DataField = "FirstName";
 col.HeaderText = (string)GetLocalResourceObject("grid_PanelistFirstName");
 col.UniqueName = "FirstName";
 grid.MasterTableView.Columns.Add(col);

 col = new GridBoundColumn();
 col.DataField = "LastName";
 col.HeaderText = (string)GetLocalResourceObject("grid_PanelistLastName");
 col.UniqueName = "LastName";
 grid.MasterTableView.Columns.Add(col);

 col = new GridBoundColumn();
 col.DataField = "Email";
 col.HeaderText = (string)GetLocalResourceObject("grid_PanelistEmail");
 col.UniqueName = "Email";
 grid.MasterTableView.Columns.Add(col);

 GridCheckBoxColumn chk;
 chk = new GridCheckBoxColumn();
 chk.DataField = "IsOptIn";
 chk.HeaderText = (string)GetLocalResourceObject("grid_PanelistOptIn");
 chk.ReadOnly = true;
 grid.MasterTableView.Columns.Add(chk);

 GridClientSelectColumn select = new GridClientSelectColumn();
 grid.MasterTableView.Columns.Add(select);

 return grid;
}

protected void PopulatePanelistGrid(List<int> ids)
{
 RadGrid grid = DefineGridStructure();
 grid.DataSource = GetPanelistData(ids);
 grid.DataBind();
 pnl_gridPanel.Controls.Add(grid);
}

Oh, the method PopulatePanelistGrid is called on Page_Load.

Thank you,
James

1 Answer, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 07 Sep 2011, 10:48 PM

I have the issue kind of solved, everything works fine if I bind the data through the GridNeedDataSourceEventHandler ie: grid.NeedDataSource += new GridDataSourceEventHandler(grid_NeedDataSource)

I would prefer to be able to manually bind the data though so if anyone has any suggestions it would be greatly appreciated.

Thank you,
James

 

 

Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Share this question
or