[CLOSED] CheckboxSelectionModel + conditional select

  1. #1

    [CLOSED] CheckboxSelectionModel + conditional select



    Hi,

    I have a gridpanel with a checkboxselectionmodel. The row may only be selected if i click on the first column (checkbox column) of the row. That all works fine.
    Than, when i click on my button (btnSendPreManifest), i want to send the values of the selected rows to an ajaxmethod, so I pass the variable 'Ext.encode(#{GridPanelPreManifest}.getRowsValues( ))'

    Now the problem is the length of the getRowsValues() doesn't equal the checkbox's selected in my gridpanel. It equals the times i clicked on a row, so for example, if a checked one Checkbox and i clicked several times in another column of another row, then the items length of the getRowsValues() is for example 10 instead of 1.

    This is the code of my gridpanel:

    
    
    
    <ext:GridPanel runat="server" ID="GridPanelPreManifest" StoreID="StorePreManifest" AutoExpandColumn="VesselName" Border="false">
    
    
    <ColumnModel ID="ColumnModelForwarder" runat="server">
    
    
    <Columns> 
    
    
    <ext:Column DataIndex="VesselName" ColumnID="VesselName" Sortable="true" Header="Vessel" /> 
    
    
    <ext:Column DataIndex="VesselDepartureDate" Sortable="true" Header="Departure Date" Width="120">
    
    
    <Renderer Fn="Ext.util.Format.dateRenderer('d/m/Y h:i:s')" />
    
    
    </ext:Column>
    
    
    <ext:Column DataIndex="Forwarder" Sortable="false" Header="Forwarder" /> 
    
    
    <ext:Column DataIndex="PortOfDischarge" Sortable="false" Header="Port Of Discharge" /> 
    
    
    <ext:Column DataIndex="TotalUnits" Sortable="false" Header="# Units" Width="50" />
    
    
    <ext:Column DataIndex="Format" Header="Format"> 
    
    
    <Renderer Fn="formatRenderer" /> 
    
    
    <Editor>
    
    
    <ext:ComboBox ID="cboFormat" runat="server" TriggerAction="All" Mode="Local" 
    
    
    StoreID="StoreFormat" DisplayField="Name" ValueField="ID"> 
    
    
    </ext:ComboBox>
    
    
    </Editor>
    
    
    </ext:Column> 
    
    
    <ext:ImageCommandColumn Width="30">
    
    
    <Commands>
    
    
    <ext:ImageCommand Icon="NoteGo" CommandName="ShowUnits">
    
    
    <ToolTip Text="Show Units" />
    
    
    </ext:ImageCommand>
    
    
    </Commands> 
    
    
    </ext:ImageCommandColumn> 
    
    
    </Columns>
    
    
    </ColumnModel>
    
    
    <LoadMask ShowMask="true" />
    
    
    <SaveMask ShowMask="true" />
    
    
    <Listeners>
    
    
    <Command Handler="Coolite.AjaxMethods.ShowUnits(record.data.VesselScheduleID, record.data.ForwarderID, record.data.PortOfDischargeID);" />
    
    
    <CellClick Fn="conditionalSelect" />
    
    
    </Listeners>
    
    
    <SelectionModel> 
    
    
    <ext:CheckboxSelectionModel ID="CheckboxSelectionModelPreManifest" runat="server" SingleSelect="false" >
    
    
    </ext:CheckboxSelectionModel> 
    
    
    </SelectionModel> 
    
    
    <BottomBar>
    
    
    <ext:PagingToolBar ID="PagingToolBarPreManifest" 
    
    
    runat="server" 
    
    
    PageSize="20" 
    
    
    StoreID="StorePreManifest"
    
    
    DisplayInfo="true"
    
    
    DisplayMsg="Displaying pre-manifests {0} - {1} of {2}" 
    
    
    EmptyMsg="No pre-manifests to display" >
    
    
    <Items>
    
    
    <ext:ToolbarSpacer ID="ToolbarSpacer2" runat="server" />
    
    
    <ext:ToolbarSeparator ID="ToolbarSeparator2" runat="server" />
    
    
    <ext:ComboBox ID="cboPreManifestRecordsPerPage" runat="server" 
    
    
    Title="Records per page" 
    
    
    Width="120" 
    
    
    Editable="false">
    
    
    <Items>
    
    
    <ext:ListItem Text="15" Value="15" />
    
    
    <ext:ListItem Text="20" Value="20" />
    
    
    <ext:ListItem Text="50" Value="50" />
    
    
    <ext:ListItem Text="100" Value="100" />
    
    
    </Items>
    
    
    <SelectedItem Text="20" Value="20" />
    
    
    <Listeners>
    
    
    <Select Handler="Coolite.AjaxMethods.ChangePreManifestRecordsPerPage();" />
    
    
    </Listeners>
    
    
    </ext:ComboBox>
    
    
    </Items>
    
    
    </ext:PagingToolBar>
    
    
    </BottomBar>
    
    
    <KeyMap> 
    
    
    <ext:KeyBinding>
    
    
    <Keys>
    
    
    <ext:Key Code="LEFT" />
    
    
    </Keys>
    
    
    <Listeners>
    
    
    <Event Handler="if (#{hiddenPreManifestStoreIsLoading}.value=='NO' &amp;&amp; #{PagingToolbarPreManifest}.activePageField.value-1 > 0) {#{PagingToolbarPreManifest}.changePage(#{PagingToolbarPreManifest}.activePageField.value-1);};" />
    
    
    </Listeners>
    
    
    </ext:KeyBinding> 
    
    
    <ext:KeyBinding>
    
    
    <Keys>
    
    
    <ext:Key Code="RIGHT" />
    
    
    </Keys>
    
    
    <Listeners>
    
    
    <Event Handler="if (#{hiddenPreManifestStoreIsLoading}.value=='NO' &amp;&amp; #{PagingToolbarPreManifest}.activePageField.value+1 < #{PagingToolbarPreManifest}.getPageData().pages+1 ) {#{PagingToolbarPreManifest}.changePage(#{PagingToolbarPreManifest}.activePageField.value+1);};" />
    
    
    </Listeners>
    
    
    </ext:KeyBinding> 
    
    
    </KeyMap>
    
    
    <Buttons>
    
    
    <ext:Button ID="btnSendPreManifest" runat="server" 
    
    
    StyleSpec="padding-top:10px;"
    
    
    Text="Send Pre-Manifest"
    
    
    >
    
    
    <Listeners>
    
    
    <Click Handler="if(#{GridPanelPreManifest}.getSelectionModel().hasSelection()) {
    
    
    Ext.Msg.confirm('Send Pre-Manifest', 'Are you sure u want to send this pre-manifests?', function(btn) {
    
    
    if (btn == 'yes') {
    
    
    Coolite.AjaxMethods.SendPreManifest(Ext.encode(#{GridPanelPreManifest}.getRowsValues()));
    
    
    } 
    
    
    });
    
    
    }else{
    
    
    Ext.Msg.alert('Pre-Manifest', 'U first have to select one or more pre-manifests.');
    
    
    };" />
    
    
    </Listeners>
    
    
    </ext:Button>
    
    
    </Buttons>
    
    
    </ext:GridPanel>
    This is the script i call when i select/deselect a row:

    
    
    
    conditionalSelect = function(a, b, c) { // a, row, column
    
    
    if (c == 0) {
    
    
    if (CheckboxSelectionModelPreManifest.isSelected(b)) {
    
    
    CheckboxSelectionModelPreManifest.unlock()
    
    
    CheckboxSelectionModelPreManifest.deselectRow(b)
    
    
    CheckboxSelectionModelPreManifest.lock()
    
    
    GridPanelPreManifest.updateSelectedRows()
    
    
    } else {
    
    
    CheckboxSelectionModelPreManifest.unlock()
    
    
    CheckboxSelectionModelPreManifest.selectRow(b, true)
    
    
    CheckboxSelectionModelPreManifest.lock()
    
    
    GridPanelPreManifest.updateSelectedRows()
    
    
    }
    
    
    } 
    
    
    }
    And the code behind when i click on the button 'btnSendPremanifest'

    
    
    
    <AjaxMethod()> _
    
    
    Public Sub SendPreManifest(ByVal json As System.String)
    
    
    Dim Model As CheckboxSelectionModel
    
    
    Dim XML As XmlNode
    
    
    Dim PreManifestID As Integer
    
    
    Dim SendFormat As System.String
    
    
    Dim VesselID As System.Int32
    
    
    Dim VesselDepartureDate As System.DateTime
    
    
    Dim ForwarderID As System.Int32
    
    
    Dim PortOfDischargeID As System.Int32
    
    
    Model = Me.GridPanelPreManifest.SelectionModel.Primary
    
    
    Try
    
    
    XML = Coolite.Ext.Web.JSON.DeserializeXmlNode("{records:{record:" + json + "}}")
    
    
    For Each Row As XmlNode In XML.SelectNodes("records/record")
    
    
    ' get row values
    
    
    VesselID = Convert.ToInt32(Row.SelectSingleNode("VesselID").InnerXml)
    
    
    VesselDepartureDate = Convert.ToDateTime(Row.SelectSingleNode("VesselDepartureDate").InnerXml)
    
    
    ForwarderID = Convert.ToInt32(Row.SelectSingleNode("ForwarderID").InnerXml)
    
    
    PortOfDischargeID = Convert.ToInt32(Row.SelectSingleNode("PortOfDischargeID").InnerXml)
    
    
    SendFormat = Convert.ToString(Row.SelectSingleNode("Format").InnerXml)
    
    
    Select Case SendFormat
    
    
    Case "1"
    
    
    SendFormat = FORMAT_EXCEL
    
    
    Case "2"
    
    
    SendFormat = FORMAL_PDF
    
    
    Case Else
    
    
    SendFormat = FORMAT_EXCEL
    
    
    End Select
    
    
     
    
    
    ' create a new pre-manifest
    
    
    PreManifestID = PreManifestBusiness.InsertPreManifest(VesselID, VesselDepartureDate, PortOfDischargeID, ForwarderID, True, SendFormat)
    
    
    Next
    
    
    ' Clear selection
    
    
    Model.SelectedRows.Clear()
    
    
    Model.UpdateSelection()
    
    
    Me.StorePreManifest.DataBind()
    
    
    Me.StoreUnit.DataBind()
    
    
    Catch ex As Exception
    
    
    CooliteHelper.DisplayProcessResultToClient(New ProcessResult(New ProcessMessage("Failed to send parking list.", False)), Me.Page, Me.ScriptManager1)
    
    
    End Try
    
    
    End Sub

    So generally, the problem is that the lenght of #{GridPanelPreManifest}.getRowsValues()


    doesn't equal the lenght of the rows selected in my gridpanel.

    Thanx!
  2. #2

    RE: [CLOSED] CheckboxSelectionModel + conditional select

    Hi,

    Please create simple example which we can test without any changes from our side.
    I played with getRowValues function and it works correctly.


    Can you change the following example for reproducing your problem?


    https://examples1.ext.net/#/GridPane...itting_Values/




Similar Threads

  1. [CLOSED] Conditional Confirmation
    By rmelancon in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 12, 2011, 2:46 PM
  2. [CLOSED] CheckboxSelectionModel multiple select
    By sriram in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 01, 2011, 8:56 PM
  3. Replies: 6
    Last Post: Aug 24, 2009, 5:22 PM
  4. Replies: 0
    Last Post: Jun 07, 2009, 11:35 PM
  5. Conditional AjaxEvents
    By grmontero in forum 1.x Help
    Replies: 1
    Last Post: May 29, 2009, 10:40 AM

Posting Permissions