Problem with SelectedRecordID from Grid RowSelectionModel

  1. #1

    Problem with SelectedRecordID from Grid RowSelectionModel

    Hello,

    I have a problem with RowSelectionModel's SelectedRecordID property at codebehind.
    I have two grids (shown below):

    		<ext:GridPanel EnableColumnHide="false" ID="grdSalidas" runat="server" Width="285" Height="400" Title="Destinos">
    			<Store>
    				<ext:Store ID="dtSalidas" runat="server">
    					<Reader>
    						<ext:JsonReader IDProperty="Id_Ciudad">
    							<Fields>
    								<ext:RecordField Name="Id_Ciudad" Mapping="Id_Ciudad" Type="Int" />
    								<ext:RecordField Name="Nombre" Mapping="Nombre" Type="String" />
    							</Fields>
    						</ext:JsonReader>
    					</Reader>
    				</ext:Store>
    			</Store>
    			<SelectionModel>
    				<ext:RowSelectionModel ID="rsmSalidas" runat="server" SingleSelect="true" />
    			</SelectionModel>
    			<ColumnModel>
    				<Columns>
    					<ext:Column Header="Id_Ciudad" DataIndex="Id_Ciudad" 
    						Width="50" Sortable="false" Hidden="true" Groupable="false">
    					</ext:Column>
    					<ext:Column Header="Destino" DataIndex="Nombre" Width="200" Groupable="false" Sortable="false" />
    				</Columns>
    			</ColumnModel>
    			<DirectEvents>
    				<RowClick OnEvent="SeleccionandoDestino" Delay="1">
    					<ExtraParams> 
    					    <ext:Parameter Mode="Raw" Name="e" Value="Ext.encode(#{grdSalidas}.getRowsValues({selectedOnly:true}))"></ext:Parameter>
    					</ExtraParams>
    					<EventMask ShowMask="true" MinDelay="5" />
    				</RowClick>
    			</DirectEvents>
    		</ext:GridPanel>
    
    		<ext:GridPanel EnableColumnHide="false" ID="grdTarifas" runat="server" Width="285" Height="200" Title="Tarifas">
    			<Store>
    				<ext:Store ID="dtTarifas" runat="server">
    					<Reader>
    						<ext:JsonReader IDProperty="Id_tipo_tarifa">
    							<Fields>
    								<ext:RecordField Name="Id_tipo_tarifa" Mapping="Id_tipo_tarifa" Type="Int" />
    								<ext:RecordField Name="Nombre" Mapping="Nombre" Type="String" />
    							</Fields>
    						</ext:JsonReader>
    					</Reader>
    				</ext:Store>
    			</Store>
    			<SelectionModel>
    				<ext:RowSelectionModel ID="rsmTarifas" runat="server" SingleSelect="true" />
    			</SelectionModel>
    			<ColumnModel>
    				<Columns>
    					<ext:Column Header="Tipo_Tarifa" DataIndex="Id_Tipo_Tarifa" Width="100" Sortable="false" Hidden="true" Groupable="false" />
    					<ext:Column Header="Tarifa" DataIndex="Nombre" Width="200" Groupable="false" Sortable="false" />
    				</Columns>
    			</ColumnModel>
    			<DirectEvents>
    				<RowClick OnEvent="SeleccionandoTarifa" Delay="1">
    					<ExtraParams> 
    					    <ext:Parameter Mode="Raw" Name="e" Value="Ext.encode(#{grdTarifas}.getRowsValues({selectedOnly:true}))"></ext:Parameter>
    					</ExtraParams>
    					<EventMask ShowMask="true" MinDelay="5" />
    				</RowClick>
    			</DirectEvents>
    		</ext:GridPanel>
    When I click on a row in the first grid (grdSalidas), an event is fired in codebehind (SeleccionandoDestino). In that event, I clear selections on second grid (grdTarifas) and select its first row:

        protected void SeleccionandoDestino(object sender, DirectEventArgs e)
        {
            string json = e.ExtraParams["e"].ToString();
            Dictionary<string, string>[] ciudad_elim = JSON.Deserialize<Dictionary<string, string>[]>(json);
    
            foreach (Dictionary<string, string> row in ciudad_elim)
            {
                foreach (KeyValuePair<string, string> keyValuePair in row)
                {
                    if (keyValuePair.Key == "Id_Ciudad")
                    {
                        rsmTarifas.ClearSelections();
                        rsmTarifas.SelectedRows.Add(new SelectedRow(0));
                        rsmTarifas.UpdateSelection();
                        long id_tarifa = Convert.ToInt64(rsmTarifas.SelectedRecordID);
                        //...
                        break;
                    }
                }
            }
        }
    The problem is that after
    rsmTarifas.UpdateSelection()
    , the property
    rsmTarifas.SelectedRecordID
    is empty, doesn't have the record ID for selected row. Also, even when
    rsmTarifas.SelectedRow
    is not null, it's property
    rsmTarifas.SelectedRow.RecordID
    is empty.

    Any hint?
    Thank you
    Regards
    Alex
  2. #2
    Solved moving code in DirectEvent method to clientside.

Similar Threads

  1. [CLOSED] Why is SelectedRecordID empty?
    By osef in forum 2.x Premium Help
    Replies: 2
    Last Post: Dec 24, 2013, 4:46 AM
  2. [CLOSED] RowSelectionModel RowSelect Handler problem
    By vadym.f in forum 1.x Premium Help
    Replies: 3
    Last Post: Jun 28, 2012, 9:52 PM
  3. [CLOSED] RowSelectionModel RowSelect Handler problem
    By vadym.f in forum 1.x Premium Help
    Replies: 13
    Last Post: Jun 22, 2012, 5:36 PM
  4. ImageCommand and SelectedRecordID
    By reiben in forum 1.x Help
    Replies: 1
    Last Post: Nov 19, 2010, 10:24 PM
  5. Replies: 0
    Last Post: Apr 20, 2010, 9:54 AM

Tags for this Thread

Posting Permissions