How to Check Grid row is selected or not in Handler

  1. #1

    How to Check Grid row is selected or not in Handler

    Hello,

    I have ext grid view and in top bar there are some buttons to save and delete the grid view rows. So, I want the validate the grid view by checking is any grid row is selected before passing control to the server. So, how can I check this in handler. or in before="....".

    Can anyone help me out of this problem.

    Thanks,
    Rahul Dhamale.
  2. #2
    Hi,

    It can look something like this:
    <Click OnEvent="DirectEvent_Clilck" Before="return GridPanel1.getSelectionModel().hasSelection()">
  3. #3
    Hi Daniil,
    By executing below code and also above code nothing is happening. And also message box is not displaying.

    <DirectEvents>
               <Click OnEvent="btnDelete_Click" Before="if(grdCreateUser.getSelectionModel().hasSelection()){alert('selected');}else{alert('not selected');}" >
                         </Click>
      </DirectEvents>
    Thanks,
    Rahul Dhamale.
  4. #4
    Please provide a sample to reproduce.
  5. #5
    Hello Daniil,

    The code is as below:

    <ext:GridPanel ID="grdRoles" runat="server" StripeRows="true" Title="Array Grid"
                            TrackMouseOver="true" Height="300" width="800" AutoHeight="false" Header="false" AutoScroll="false">
                            <TopBar>
                                <ext:Toolbar ID="toolBar1" runat="server" AutoHeight="true" AutoWidth="true">
                                    <Items>
                                        <ext:Button ID="btnAdd" runat="server" ToolTip="Add" Text="Add" Icon="Add">
                                            <DirectEvents>
                                                <Click OnEvent="btnAdd_Click" />
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:ToolbarSeparator />
                                        <ext:Button ID="btnDelete" runat="server" Text="Delete" ToolTip="Delete" Icon="Exclamation">
                                       
                                            <DirectEvents>
                                                <Click OnEvent="btnDelete_Click" Before="return grdRoles.getSelectionModel().hasSelection();">
                                                    <ExtraParams>
                                                        <ext:Parameter Name="Grid1" Value="Ext.encode(#{grdRoles}.getRowsValues({selectedOnly : true}))"
                                                            Mode="Raw" />
                                                    </ExtraParams>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                       </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <Store>
                                <ext:Store ID="Store1" runat="server" OnRefreshData="Refresh_Data"  AutoLoad="true" >
                                    <Reader>
                                        <ext:JsonReader>
                                            <Fields>
                                                <ext:RecordField Name="roleDesc" />
                                                <ext:RecordField Name="roleId" Type="Int" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                </ext:Store>
                            </Store>
                            <ColumnModel ID="ColumnModel1" runat="server">
                                <Columns>
                                    <ext:Column ColumnID="Id" DataIndex="roleId" Hidden="true" Header="Role Id" />
                                    <ext:Column Header="Role Description" DataIndex="roleDesc" Width="600" />
                                </Columns>
                            </ColumnModel>
                            <LoadMask ShowMask="true" />
                            <Plugins>
                                <ext:GridFilters runat="server" ID="GridFilters1" Local="true">
                                    <Filters>
                                        <ext:StringFilter DataIndex="roleId" />
                                        <ext:StringFilter DataIndex="roleDesc" />
                                    </Filters>
                                </ext:GridFilters>
                            </Plugins>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                            </SelectionModel>
                            <BottomBar>
                                <ext:PagingToolbar ID="PagingToolBar1" AutoDoLayout="true" AutoDataBind="true" AutoScroll="false" AutoHeight="false" runat="server" PageSize="8" DisplayInfo="true"
                                     AutoWidth="true" />
                            </BottomBar>
                        </ext:GridPanel>

    Regards,
    Rahul.
  6. #6
    Do you have any JavaScript errors?

    Regarding to:
    <Click 
        OnEvent="btnDelete_Click" 
        Before="return grdRoles.getSelectionModel().hasSelection();">
    Please replace
    return grdRoles.getSelectionModel().hasSelection();
    with
    return #{grdRoles}.getSelectionModel().hasSelection();
    Does it help?
  7. #7
    Hello Daniil,

    Regarding first script, It didn't raised any error for java script.

    Your answer works for me. Thanks once again.

    Thanks and Regards,
    Rahul Dhamale.

Similar Threads

  1. Replies: 2
    Last Post: Sep 12, 2012, 10:28 AM
  2. Check checkbox in grid
    By reiben in forum 1.x Help
    Replies: 2
    Last Post: Mar 24, 2011, 5:15 PM
  3. Replies: 3
    Last Post: Dec 21, 2010, 2:57 PM
  4. [CLOSED] Check All in Coolite Grid
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 26, 2010, 2:10 PM
  5. How to check if Form or Editable Grid is Dirty ?
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 1
    Last Post: Aug 31, 2009, 5:03 PM

Posting Permissions