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

[Solved] Grid Row select problem

6 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
arijit
Top achievements
Rank 1
arijit asked on 07 Dec 2009, 04:30 PM

I one of the grid I set

<

 

ClientSettings Selecting-AllowRowSelect="true">

 

 

</ClientSettings>

 

it is selecting without problem

But it is not working for the anchor,  like i have the following

<

 

telerik:GridTemplateColumn HeaderText="Phone Number">

 

 

<ItemTemplate>

 

 

<a title="Play" ><%# Eval("PhoneNum")%></a>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 
Please help me select the row when i click on the anchor
Regards
Arijit

6 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 07 Dec 2009, 05:52 PM
Hello Arijit,

 This is an expected behavior. You could try the following workaround to sidestep it:

<script type="text/javascript">
    function toggleSelection(sender, e)
    {
        e = e || window.event;
        var masterTable = $find('<%= RadGrid1.ClientID %>').get_masterTableView();
        var selectedItems = masterTable.get_selectedItems().length;
        var rowElement = sender.parentNode.parentNode;
        var itemIndex = rowElement.id.split("__")[1];
        if (rowElement.className.indexOf("rgSelectedRow") != -1)
        {
            if (selectedItems > 1 || e.ctrlKey == true) masterTable.deselectItem(itemIndex);
        }
        else
        {
            if (e.ctrlKey == false)
                masterTable.clearSelectedItems();
            masterTable.selectItem(itemIndex);
        }
    }
</script>

<telerik:GridTemplateColumn HeaderText="Phone Number">
    <ItemTemplate>
        <a title="Play" onclick="toggleSelection(this, event)">Something</a>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
arijit
Top achievements
Rank 1
answered on 08 Dec 2009, 04:07 PM
Great, that worked
But when I am changing the selected color by using this

 

Skin

 

="Office2007" SelectedItemStyle-BackColor="Blue"

 

 

 

 

 

 

It is only changing color of the bottom portion, how can i change the selected row color ?

Please help
Regards
Arijit Chatterjee

 

 

 

 

 

0
Accepted
Princy
Top achievements
Rank 2
answered on 09 Dec 2009, 07:07 AM
Hello Arijit,

Try using a CssClass to set the style for the selected item as shown below:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" 
SelectedItemStyle-CssClass="myselectedclass" AutoGenerateColumns="false"  ...> 

css:
.myselectedclass 
   { 
      background:Blue !important; 
   } 

Thanks
Princy.
0
arijit
Top achievements
Rank 1
answered on 09 Dec 2009, 06:00 PM
It worked but with one odd orange border

then i applied 

 

.myselectedclass

 

{

 

border:solid 1px Blue;

 

 

background:Blue !important;
}
It didn't work

Please Help
Regards
Arijit

 

0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Dec 2009, 05:30 AM
Hi Arijit,

Try setting the border style for the selected item using the CssClass shown below:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" 
SelectedItemStyle-CssClass="myselectedclass" AutoGenerateColumns="false"  ...> 

css:
 .myselectedclass 
   { 
     background:Blue !important; 
     color:White !important; 
   } 
 .myselectedclass td 
   { 
     border-top:solid 1px Blue !important;  
     border-bottom:solid 1px Blue !important;  
   } 

Hope this helps..
Princy.
0
arijit
Top achievements
Rank 1
answered on 10 Dec 2009, 06:13 PM
Thanx Princy
Tags
Grid
Asked by
arijit
Top achievements
Rank 1
Answers by
Daniel
Telerik team
arijit
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or