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

Grid selection

1 Answer 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seban
Top achievements
Rank 1
Seban asked on 16 May 2014, 07:23 AM
Sir, I have a grid , its containing template columns and bounded columns,
  Onclientclicked event of a check box column , i do all checkbox expect the current cell are set  false.
this code is working correctely 
, but i also need  another bounded columns values are displayed, thats colums are visible is false.

please help me.
very urgent.

by , seban
 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 May 2014, 06:24 AM
Hi Seban,

I guess on the checkbox click you want to access a BoundColumn which is hidden. Please make sure that you hide the column with the Display="false", if you set the Visible property it cannot be accessed in server or clientside. Please take a look at the sample code snippet. If this is not your requirement elaborate on it and provide your code.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnItemDataBound="RadGrid1_ItemDataBound1">
    <MasterTableView ClientDataKeyNames="OrderID">
        <Columns>
            <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <asp:CheckBox ID="chkStatus" runat="server" AutoPostBack="true" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>          
            <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" Display="false">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_ItemDataBound1(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
    GridDataItem dataItem = (GridDataItem)e.Item;
    CheckBox chkStatus = (CheckBox)dataItem.FindControl("chkStatus");
    int index = dataItem.ItemIndex;
    chkStatus.Attributes.Add("onclick", "demo('" + index + "')");
  }
}

JS:
<script type="text/javascript">
  function demo(index) {
      var MasterTable = $find('<%= RadGrid1.ClientID %>').get_masterTableView();
      var row = MasterTable.get_dataItems()[index];
      //Accessing a boundcolumn row
      var cell = MasterTable.getCellByColumnUniqueName(row, "ShipCity");
      alert(cell.innerHTML); //get cell value
      alert(row.getDataKeyValue("OrderID")); //get ClientDataKeyName
    }  
</script>

Thanks,
Princy
Tags
Grid
Asked by
Seban
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or