Dec 01, 2009, 3:48 PM
Select rows in a Grid with a list of record Id
Hi guys,
I have a question about the method SelectRecords in RowSelectionModel. I have a gridpanel linked with a store object.
The datasource of the store is a simple object list with the properties Id and name.
How I can get it?
Thanks!!!!
I have a question about the method SelectRecords in RowSelectionModel. I have a gridpanel linked with a store object.
The datasource of the store is a simple object list with the properties Id and name.
<ext:Store ID="store1" runat="server" >
<Reader>
<ext:JsonReader ReaderID="Id" >
<Fields>
<ext:RecordField Name="Id" Type="Int"></ext:RecordField>
<ext:RecordField Name="name"></ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
The grid code is this <ext:GridPanel
runat="server"
ID="gridpanel1"
StoreID="store1">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ColumnID="name" DataIndex="name" Header="NAME" ></ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel ID="CheckboxSelectionModel9" runat="server" HideCheckAll="true" />
</SelectionModel>
</ext:GridPanel>
And I have a button with ajax event. The button should select an specific row in server side, not by row index, but by RecordID. Then I have this code in server side (VB.NET)
Protected Sub selectARow(ByVal sender As Object, ByVal e As AjaxEventArgs)
Dim selectionModel As RowSelectionModel = CType(Me.gridpanel1.SelectionModel.First, RowSelectionModel)
selectionModel.SelectRecords(New Integer() {67}, True) '67 is the Id of an object in the datasource list of objects.
End Sub
But nothing happens, the specific record is not selected. If I use the next method, the second row is selected, but I don't need select rows by the order. I need select rows by their Record Id.
Protected Sub selectARow(ByVal sender As Object, ByVal e As AjaxEventArgs)
Dim selectionModel As RowSelectionModel = CType(Me.gridpanel1.SelectionModel.First, RowSelectionModel)
selectionModel.SelectRow(1, True)
End Sub
How I can get it?
Thanks!!!!