or
| function ExpandCollapseFirstMasterTableViewItem() |
| { |
| debugger; |
| var firstMasterTableViewRow = document.getElementById("<%= RadGrid1.MasterTableView.ClientID %>").get_dataItems()[0]; |
| if(firstMasterTableViewRow.get_expanded()) |
| { |
| firstMasterTableViewRow.set_expanded(false); |
| } |
| else |
| { |
| firstMasterTableViewRow.set_expanded(true); |
| } |
| } |
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
|
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestProgrammaticRadGrid.aspx.cs" Inherits="Test_TestProgrammaticRadGrid" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| <telerik:RadCodeBlock runat="server"> |
| <script language="javascript" type="text/javascript"> |
| function TestButton_onclick() |
| { |
| var radGrid = $find('<%=TestRadGrid.ClientID %>'); |
| var rows = radGrid.get_masterTableView().get_dataItems(); |
| alert('# items: ' + rows.length); |
| alert('first PK: ' + rows[0].getDataKeyValue('ID')); |
| } |
| </script> |
| </telerik:RadCodeBlock> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <asp:ScriptManager ID="ScriptManager1" runat="server"> |
| </asp:ScriptManager> |
| <asp:PlaceHolder ID="GridPlaceholder" runat="server" /> |
| <input type="button" id="TestButton" value="Click Here" onclick="return TestButton_onclick();" /> |
| </div> |
| </form> |
| </body> |
| </html> |
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Web; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using Telerik.Web.UI; |
| public partial class Test_TestProgrammaticRadGrid : System.Web.UI.Page |
| { |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!IsPostBack) |
| PopulateGrid(); |
| } |
| private void PopulateGrid() |
| { |
| List<TestData> list = new List<TestData>(); |
| for (int i = 0; i < 11; i++) |
| list.Add(new TestData(i, "test " + i.ToString())); |
| TestRadGrid.DataSource = list; |
| TestRadGrid.DataBind(); |
| } |
| protected void Page_Init(object sender, EventArgs e) |
| { |
| DefineGridStructure(); |
| } |
| private void DefineGridStructure() |
| { |
| TestRadGrid = new RadGrid(); |
| TestRadGrid.AutoGenerateColumns = false; |
| InitializeProblemGrid(TestRadGrid); |
| AddCenteredColumn(TestRadGrid, "ID", "ID", "ID"); |
| AddCenteredColumn(TestRadGrid, "Name", "Name", "Name"); |
| GridPlaceholder.Controls.Add(TestRadGrid); |
| } |
| private void InitializeProblemGrid(RadGrid radGrid) |
| { |
| radGrid.MasterTableView.DataKeyNames = new string[] { "ID" }; |
| radGrid.ClientSettings.Selecting.AllowRowSelect = true; |
| } |
| private void AddCenteredColumn(RadGrid radGrid, string uniqueName, string headerText, string dataField) |
| { |
| GridBoundColumn column = new GridBoundColumn(); |
| column.UniqueName = uniqueName; |
| column.HeaderText = headerText; |
| column.DataField = dataField; |
| column.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; |
| column.ItemStyle.HorizontalAlign = HorizontalAlign.Center; |
| radGrid.MasterTableView.Columns.Add(column); |
| } |
| private RadGrid _TestRadGrid; |
| protected RadGrid TestRadGrid |
| { |
| get { return _TestRadGrid; } |
| set { _TestRadGrid = value; } |
| } |
| } |
| public class TestData |
| { |
| public TestData(int id, string name) |
| { |
| _ID = id; |
| _Name = name; |
| } |
| public int ID |
| { |
| get { return _ID; } |
| set { _ID = value; } |
| } |
| public string Name |
| { |
| get { return _Name; } |
| set { _Name = value; } |
| } |
| private int _ID; |
| private string _Name; |
| } |
I'm using the Q2 2008 build, dll's show product version 2008.02.0826.20.
--Mark