[CLOSED] Getting and setting the current page of a grid panel based on the selected row.
I have a grid panel that is loaded with say 40 items and the page size is set to 10. In code behind I am selecting a row based on a value from the database. As an example lets assume it is on page 3. I can set the grid to show page 3 in code behind using nameOfStore.LoadPage(3) which works. The problem is I can't figure out how to programatically determine the record index or page on which the selected row resides.
This is the code behind that sets the selected row based on a rowID:
Code:
Dim rowID As String = Nothing
rowID = String.Format("{0}|{1}", "textKey", ID_in)
Dim sm As CheckboxSelectionModel = grdComposite.GetSelectionModel
sm.ClearSelection()
sm.SelectedRows.Add(New SelectedRow(rowID))
In all cases sm.SelectedIndex and sm.SelectedRow.RowIndex are always -1 and I don't see any other property that would tell me the row number of the record I selected. Once I have that I can use that and the PageSize to determine which page to load.
This is some of the grid markup:
Code:
<ext:GridPanel
runat="server"
ID="grdComposite"
Title="Select a Composite Allocation"
BodyPadding="15"
Padding="10"
HeightSpec="100%">
<Store>
<ext:Store
runat="server"
ID="strComposite"
PageSize="10">
<Model>
<ext:Model runat="server" IDProperty="RowID">
<Fields>
<ext:ModelField Name="RowID" Type="String" />
<ext:ModelField Name="CompositeID" Type="String" />
<ext:ModelField Name="CompositeName" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<View>
<ext:GridView
runat="server"
TrackOver="false"
EmptyText="No composites available.">
<GetRowClass Handler="return record.get('RangeClass');" />
</ext:GridView>
</View>
<ColumnModel>
<Columns>
<ext:Column
runat="server"
ColumnID="colCompositeName"
Header="Composite"
DataIndex="CompositeName"
Flex="1"
MenuDisabled="true">
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel
runat="server"
ID="grdCompositeSelectionModel"
AllowDeselect="false"
Mode="Single">
<DirectEvents>
<Select
OnEvent="grdCompositeSelectionModel_RowSelect" Before="maskInsightPanels(true)">
<ExtraParams>
<ext:Parameter Name="investmentid" Value="record.getId()" Mode="Raw" />
<ext:Parameter Name="productminimums" Value="record.productminimums" Mode="Raw" />
<ext:Parameter Name="Values" Value="Ext.encode(#{grdComposite}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:CheckboxSelectionModel>
</SelectionModel>
<BottomBar>
<ext:PagingToolbar runat="server" />
</BottomBar>
</ext:GridPanel>