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

Obtaining grid values client side issue

5 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jibber4568
Top achievements
Rank 1
Jibber4568 asked on 04 Sep 2012, 11:33 AM
Hi guys,

I've come across an issue and I was hopnig you could let me know if I'm doing something wrong or if there is a problem here.

I have a radgrid all set-up correctly. In a javascript function I need to obtain the values of the selected row, this works fine for all columns except for a column which isn't visible.

Is there a different way to retrieve values from columns where the visibility is set to false?

Grid
<telerik:RadGrid runat="server" ID="rgLzHits" AutoGenerateColumns="False">
                    <MasterTableView PagerStyle-Mode="NumericPages" EditMode="EditForms" DataKeyNames="displayid">
                        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>                                               
                        <Columns>                                                    
                            <telerik:GridBoundColumn DataField="displayid" HeaderText="displayid"
                                    UniqueName="displayid" visible="False" ReadOnly="true" ItemStyle   Width="300px">
                             </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="displayname" HeaderText="Landing Zone"
                                    UniqueName="displayname" visible="True" ReadOnly="true" ItemStyle-Width="300px">
                             </telerik:GridBoundColumn>  
                             <telerik:GridBoundColumn DataField="totalhits" HeaderText="Total"
                                    UniqueName="totalhits" visible="True" ReadOnly="true" ItemStyle-Width="300px">
                             </telerik:GridBoundColumn
                            <telerik:GridBoundColumn DataField="distincthit" HeaderText="Distinct"
                                    UniqueName="distincthit" visible="True" ReadOnly="true" ItemStyle-Width="50px">
                            </telerik:GridBoundColumn>       
                            <telerik:GridBoundColumn DataField="distinctpercent" HeaderText="Distinct %"
                                    UniqueName="distinctpercent" visible="True" ReadOnly="true" ItemStyle-Width="50px">
                            </telerik:GridBoundColumn>       
                            <telerik:GridBoundColumn DataField="AvgRating" HeaderText="Avg Rating"
                                    UniqueName="AvgRating" visible="True" ReadOnly="true" ItemStyle-Width="100px">
                            </telerik:GridBoundColumn>                                                                                                                                                                                                                                                                                                                                                                                                                 
                            <telerik:GridBoundColumn DataField="CatName" HeaderText="Category Name"
                                    UniqueName="CatName" visible="True" ReadOnly="true" ItemStyle-Width="100px">
                            </telerik:GridBoundColumn
                        </Columns>
                        <DetailTables>
                            <telerik:GridTableView runat="server" Name="LZHitsContacts" AutoGenerateColumns="false" NoDetailRecordsText="No results exist for this contact">
                                <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>     
                                <Columns>    
                                    <telerik:GridBoundColumn DataField="Firstname" HeaderText="First Name"
                                            UniqueName="Firstname" visible="True" ReadOnly="true">
                                    </telerik:GridBoundColumn>       
                                    <telerik:GridBoundColumn DataField="Lastname" HeaderText="Last Name"
                                        UniqueName="Lastname" visible="True" ReadOnly="true">
                                    </telerik:GridBoundColumn>       
                                    <telerik:GridBoundColumn DataField="EmailLogin" HeaderText="Email Address"
                                        UniqueName="EmailLogin" visible="True" ReadOnly="true">
                                    </telerik:GridBoundColumn>    
                                    <telerik:GridBoundColumn DataField="eventdate" HeaderText="Event Date"
                                        UniqueName="eventdate" visible="True" ReadOnly="true">
                                    </telerik:GridBoundColumn>  
                                    <telerik:GridBoundColumn DataField="contactrating" HeaderText="Contact Rating"
                                        UniqueName="eventdate" visible="True" ReadOnly="true">
                                    </telerik:GridBoundColumn>  
                                    <telerik:GridBoundColumn DataField="SocialMedia" HeaderText="Social Share"
                                        UniqueName="SocialMedia" visible="True" ReadOnly="true">
                                    </telerik:GridBoundColumn>                                                
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables
                    </MasterTableView>   
                    <ClientSettings EnableRowHoverStyle="True">
                        <Selecting AllowRowSelect="True"></Selecting>
                    </ClientSettings>   
                </telerik:RadGrid>

Javascript

var grid = $find("<%=rgLzHits.ClientID %>");
      var MasterTable = grid.get_masterTableView();
      var selectedRows = MasterTable.get_selectedItems();
 
     if(selectedRows != -1)
      {
          for (var i = 0; i < selectedRows.length; i++) {
           var row = selectedRows[i];
          var  SearchValue = MasterTable.getCellByColumnUniqueName(row, "displayid");            
          var PageTitle = MasterTable.getCellByColumnUniqueName(row, "displayname");             
         }
         alert(SearchValue);
         alert(PageTitle);

The alert of the pagetitle returns the object fine where as the seachvalue always returns null.

Thanks.

5 Answers, 1 is accepted

Sort by
0
Jibber4568
Top achievements
Rank 1
answered on 04 Sep 2012, 11:53 AM
Thanks for that. However that doesn't really address my problem.

I'm not having any trouble obtaining the row values, the problem is when the column has its visibility set to false.


The following works fine:
var PageTitle = MasterTable.getCellByColumnUniqueName(row, "displayname");

However the following returns null. Only difference is the column is set as visible="false"
var  SearchValue = MasterTable.getCellByColumnUniqueName(row, "displayid");

Thanks.

       
0
Accepted
Princy
Top achievements
Rank 2
answered on 04 Sep 2012, 11:57 AM
Hi,

One suggestion is that you can set the column's Display property as false(instead of Visible) and then access the column. Hope this helps.
aspx:
<telerik:GridBoundColumn DataField="displayid" HeaderText="displayid" UniqueName="displayid" Display="false" ReadOnly="true" ItemStyle   Width="300px">
</telerik:GridBoundColumn>

Thanks,
Princy.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 Sep 2012, 01:06 PM
Hello,

you can also set that field in ClinetDatakey and access this on client side.

OR

If you set it display:none then check "Access Column Text" this in below link.

http://jayeshgoyani.blogspot.in/2012/07/access-radgrid-on-client.html

Thanks,
Jayesh Goyani
0
Jibber4568
Top achievements
Rank 1
answered on 04 Sep 2012, 01:08 PM
Brilliant!! Cheers Princy
Tags
Grid
Asked by
Jibber4568
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Jibber4568
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or