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

Selecting Desired Records In RadGrid

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 02 Mar 2011, 06:21 AM
I am receiving records from a web service that are displayed in a
RadGrid. I need to mark certain records as selected based on the
existence of matching records in a database table. The records in
the table were produced from the web service at one time and contain
only matching records. The records are matched via the "AccDesc"
DataKeyNames. Any suggestions would be appreciated.

<
radControls:RadGrid ID="AccessoriesGrd" runat="server" Width="780px" AllowMultiRowSelection="true" Visible="true">
<MasterTableView DataKeyNames="AccDesc, Retail, TradeIn" AutoGenerateColumns="false" EnableHeaderContextMenu="true">
<Columns
<radControls:GridClientSelectColumn HeaderText="Select" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="55px" UniqueName="SelectColumn" ItemStyle-VerticalAlign="Top" />
<radControls:GridBoundColumn DataField="AccDesc" AllowSorting="true" HeaderText="Description" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="350px" ItemStyle-VerticalAlign="Top" />
<radControls:GridTemplateColumn HeaderText="Retail" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="55px" SortExpression="Retail" ItemStyle-HorizontalAlign="Right" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<%#Consumers.StandardFunctions.FormatCurrency(Eval("Retail"))%>
</ItemTemplate>
</radControls:GridTemplateColumn
<radControls:GridTemplateColumn HeaderText="Trade-In" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="55px" SortExpression="TradeIn" ItemStyle-HorizontalAlign="Right" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<%#Consumers.StandardFunctions.FormatCurrency(Eval("TradeIn"))%>
</ItemTemplate>
</radControls:GridTemplateColumn
</Columns>                  
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true" AllowColumnsReorder="true" ColumnsReorderMethod="Reorder">
<Selecting AllowRowSelect="true" />
</ClientSettings>
</radControls:RadGrid>

 

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 07 Mar 2011, 12:04 PM
Hello Wayne,

In order to implement the desired functionality, I recommend that you traverse all grid items on PreRender, check whether a record with the same AccDesc is contained in the database and set the Selected property of the corresponding grid item if there is.

Please give this approach a try and let me know how it goes.

Greetings,
Mira
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Charles
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or