2

This one I thought would be simple. How do you utalize get_masterTableView() from a radgrid thats dynamically created. You cannot use var radGrid = $find('<%= MyGrid.ClientID %>') because the grid doesnt exist in the aspx page it's found in code behind. And GetelementById finds the radgrid but it doesnt have the get_matertableview.

Any thoughts?

1 Answers1

2

At what point are you trying to call get_masterTableView()? This example should work.

ASPX:

<asp:PlaceHolder ID="phRG" runat="server"></asp:PlaceHolder>

C#:

var rg = new RadGrid();
rg.ID = "RadGrid1";
rg.ClientSettings.ClientEvents.OnGridCreated = "gridCreatedTest";
rg.MasterTableView.Columns.Add(new GridBoundColumn()
{
    UniqueName = "TransAmnt", DataField = "TransAmnt", SortExpression = "TransAmnt"
});

var batchChecks = new DataTable("checksRandomName");
batchChecks.Columns.Add("TransAmount");
batchChecks.Rows.Add(new ArrayList() { 7 }.ToArray());
batchChecks.Rows.Add(new ArrayList() { 16 }.ToArray());

var dsBatch = new DataSet("batch");
dsBatch.Tables.Add(batchChecks);

rg.VirtualItemCount = dsBatch.Tables.Count;
rg.DataSource = dsBatch;

phRG.Controls.Add(rg);

This JavaScript function will alert the correct "7" and "16" sample values:

function gridCreatedTest() {
    var grid = $find("RadGrid1"),
        masterTable = grid.get_masterTableView(),
        rows = masterTable.get_dataItems();
    for (i = 0; i < rows.length; i++) {
        row = rows[i];
        alert(masterTable.getCellByColumnUniqueName(row, "TransAmount").innerHTML);
    }
}
DanM7
  • 2,101
  • 3
  • 25
  • 45
  • @Mike - I'm glad this answer helped. If you were doing things differently, do you want to show the code you had before? That could help other users. – DanM7 Jun 23 '14 at 19:49