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

get hidden values in a radgrid

2 Answers 241 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kranthi
Top achievements
Rank 1
Kranthi asked on 05 Jul 2012, 02:31 PM
Hi All

can anyone give me a solution to get the values binded to radgrid and made the column as hidden/visible =false

i need to get the hiddden values of the rows where checkboxes are checked, if header checkox is checked i need to get all values and use those values...

this is my radgrid

            <telerik:RadGrid ID="M" runat="server" Width="99%" AllowPaging="True" EnableViewState="False"
                GridLines="None" meta:resourcekey="MResource1" AllowFilteringByColumn="true"
                OnInit="GridControl_Init" EnableLinqExpressions="false" 
                EnableEmbeddedSkins="false" AutoGenerateColumns="False">
                <HeaderContextMenu EnableEmbeddedSkins="True">
                </HeaderContextMenu>
                <FilterMenu Skin="Nediso" EnableEmbeddedSkins="false">
                </FilterMenu>
                <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom" AlwaysVisible="true" />
                <MasterTableView Width="100%" EnableViewState="False" AllowFilteringByColumn="true">
                   <Columns>  


                   <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn" AllowFiltering="false">
                   <HeaderStyle Width="3%" HorizontalAlign="Justify" />
                    <ItemStyle Width="3%" HorizontalAlign="Justify" />
                            <HeaderTemplate>
                             <asp:CheckBox id="headerChkbox"  runat="server" onclick="SelectAll(this)"></asp:CheckBox>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                   
                     <telerik:GridBoundColumn DataField="TOKEN" Visible="false" UniqueName="TOKEN" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FIRST NAME" HeaderText="FIRST NAME" UniqueName="FIRST NAME1">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LAST NAME" HeaderText="LAST NAME" UniqueName="LAST NAME1">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="STATUS" HeaderText="STATUS" UniqueName="STATUS1">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="DESIGNATION" HeaderText="DESIGNATION" UniqueName="DESIGNATION1">
                    </telerik:GridBoundColumn>
                    </Columns>
                    <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" Position="TopAndBottom" />
                    
                </MasterTableView>
                <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" EnableRowHoverStyle="True">
                    <Resizing AllowColumnResize="True" />
                    <Selecting AllowRowSelect="True" />                    
                    <ClientEvents OnFilterMenuShowing="OnFilterMenuShowing"></ClientEvents> 
                    </ClientSettings>
                <FilterMenu EnableTheming="True">
                    <CollapseAnimation Type="None" />
                    <ExpandAnimation Type="None" />
                </FilterMenu>
            </telerik:RadGrid>

i have a button outside the grid when the button is clicked i need to get the value placed in hidden column for only which the textbox is checked..  pls reply me soon.

2 Answers, 1 is accepted

Sort by
0
Vincent
Top achievements
Rank 1
answered on 05 Jul 2012, 06:10 PM
I'm not a pro in this but I would say that you get all the selectedItems -->

foreach(GridDataItem item in M.SelectedItems)
{
string name = item["name"].Text //where ["name"] is the column header title
}

After this, you can get what you need in your data source with the info you just get from your grid.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Jul 2012, 06:20 PM
Hello,

<MasterTableView DataKeyNames="ID,Name" ClientDataKeyNames="ID,Name">
                <Columns>
                    <telerik:GridTemplateColumn>
                        <HeaderTemplate>
                            <asp:CheckBox ID="headerChkbox" runat="server" onclick="SelectAll(this)"></asp:CheckBox>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server"></asp:CheckBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
.........
..........
function SelectAll(chkh) {
                if (chkh.checked) {
                    var grid = $find("<%=dgPassanger.ClientID %>");
 
                    if (grid) {
                        var MasterTable = grid.get_masterTableView();
                        var Rows = MasterTable.get_dataItems();
                        for (var i = 0; i < Rows.length; i++) {
                            var row = Rows[i];
                            var CheckBox1 = $(row.get_element()).find("input[id*='CheckBox1']");
                            alert(CheckBox1.get(0).checked);
                            alert(row.getDataKeyValue("ID"));
                            alert(row.getDataKeyValue("Name"));
                        }
                    }
                }
            }

I am doing this functionality by using DataKey Because  visible='false' do not render to browser/client side so, we are not able to get in JS.

You can also check below link for how to access control on client in radgrid.
http://jayeshgoyani.blogspot.in/2012/05/how-to-access-control-from-itemtemplate.html

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Kranthi
Top achievements
Rank 1
Answers by
Vincent
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or