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

Selected state

3 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erick
Top achievements
Rank 2
Erick asked on 12 Sep 2011, 01:38 PM
Hi,

I've an issue with selected state of rows with custom cssclasses. I'll discribe the scenario: We have a grid with 20 addresses (name, street, city). Some records are from external source which we want to be blue (text). This works very well with cssclass, but ... After succesfully load of the girid, click on some blue record, the postback will be forced. The row is selected correctly with highlighting but after the postback is finished, the selected state is lose and is back to his normal state (rgRow or rgRowAlt).

Grid:
<telerik:RadGrid ID="grdData" Width="100%"
                                AllowPaging="True" PageSize="15" runat="server" AllowSorting="True"
                                GridLines="None" EnableLinqExpressions="False" GroupingEnabled="False"
                                AutoGenerateColumns="False" CellSpacing="0" SkinID="grdGeneral" CssClass="RadGrid">
                         
                                <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" EnablePostBackOnRowClick="true">
                                    <Selecting AllowRowSelect="True" />
                                    <Scrolling AllowScroll="True" />
                      
                                    <Resizing ClipCellContentOnResize="true" />
                                </ClientSettings>
                            
                                <MasterTableView Width="100%" ClientDataKeyNames="address_ID,type_ID" DataKeyNames="address_ID,type_ID" TableLayout="Fixed">
 
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="address_ID" UniqueName="address_ID" Visible="False" />
                                        <telerik:GridBoundColumn DataField="type_ID" UniqueName="type_ID" Visible="False" />
                                        <telerik:GridTemplateColumn UniqueName="SELECT" AllowFiltering="false" Reorderable="false" Resizable="false">
                                            <ItemStyle Width="35px" />
                                            <HeaderStyle Width="35px" />
                                            <HeaderTemplate>
                                                <asp:CheckBox ID="chkSelectAll" runat="server" />
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkSelect" runat="server" />
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="TYPE" CommandName="TYPE">
                                            <ItemStyle Width="30px" />
                                            <HeaderStyle Width="30px" />
                                        </telerik:GridButtonColumn>
                                        <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/images/edit.png" UniqueName="EDIT" CommandName="EDIT">
                                            <ItemStyle Width="30px" />
                                            <HeaderStyle Width="30px" />
                                        </telerik:GridButtonColumn>
                                        <telerik:GridBoundColumn DataField="full_name" UniqueName="full_name" HeaderText="Naam">
                                            <ItemStyle Wrap="false" CssClass="minwidth" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="city" UniqueName="city" HeaderText="Plaats">
                                            <ItemStyle Width="140px" Wrap="false" />
                                            <HeaderStyle Width="140px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="emailaddress" UniqueName="emailaddress" HeaderText="E-mailadres">
                                            <ItemStyle Width="140px" Wrap="false" />
                                            <HeaderStyle Width="140px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="phone" UniqueName="phone" HeaderText="Telefoon">
                                            <ItemStyle Width="140px" Wrap="false" />
                                            <HeaderStyle Width="140px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/images/delete.png" UniqueName="DELETE" CommandName="DELETE">
                                            <ItemStyle Width="30px" />
                                            <HeaderStyle Width="30px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
 
                                </MasterTableView>
 
                            </telerik:RadGrid>

Databound event:
Private Sub grdData_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grdData.ItemDataBound
   radItem.CssClass = IIf(radItem.ItemType = GridItemType.AlternatingItem, "rgAltRow", "rgRow") & " BlueRecord" 
End Sub

.BlueRecord
{
    color: navy !important;
}

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Sep 2011, 02:04 PM
Hello,

I tried the following CSS and it worked as expected.
CSS:
<style type="text/css">
.RadGrid_Default .rgSelectedRow td
 {
  background-color: navy !important;
 }
</style>

Thanks,
Princy.
0
Erick
Top achievements
Rank 2
answered on 12 Sep 2011, 02:22 PM
Hi,

Thanks for your idea but this is not what i wanted for.
I just want the same selected style as normal records, with one different: blue text.

This works fine but the selected state will lose after the postback.

Kind regards,

Jelle
0
Erick
Top achievements
Rank 2
answered on 12 Sep 2011, 02:29 PM
Hi,

I've fixed this with Font and ForeColor methods of griditem instead of cssclasses.
The selected state will not lose with this.

Select Case strMethod
            Case "record_primary"
                radItem.Font.Bold = True
            Case "record_external"
                radItem.ForeColor = Drawing.Color.Navy
            Case "record_noteditable"
                radItem.ForeColor = Drawing.Color.Red
            Case "record_editable"
                radItem.ForeColor = Drawing.Color.Green
        End Select
Tags
Grid
Asked by
Erick
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Erick
Top achievements
Rank 2
Share this question
or