How to Check Grid row is selected or not in Handler

  1. #1

    How to Check Grid row is selected or not in Handler


    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.

    Rahul Dhamale.
  2. #2

    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.

               <Click OnEvent="btnDelete_Click" Before="if(grdCreateUser.getSelectionModel().hasSelection()){alert('selected');}else{alert('not selected');}" >
    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">
                                <ext:Toolbar ID="toolBar1" runat="server" AutoHeight="true" AutoWidth="true">
                                        <ext:Button ID="btnAdd" runat="server" ToolTip="Add" Text="Add" Icon="Add">
                                                <Click OnEvent="btnAdd_Click" />
                                        <ext:ToolbarSeparator />
                                        <ext:Button ID="btnDelete" runat="server" Text="Delete" ToolTip="Delete" Icon="Exclamation">
                                                <Click OnEvent="btnDelete_Click" Before="return grdRoles.getSelectionModel().hasSelection();">
                                                        <ext:Parameter Name="Grid1" Value="Ext.encode(#{grdRoles}.getRowsValues({selectedOnly : true}))"
                                                            Mode="Raw" />
                                <ext:Store ID="Store1" runat="server" OnRefreshData="Refresh_Data"  AutoLoad="true" >
                                                <ext:RecordField Name="roleDesc" />
                                                <ext:RecordField Name="roleId" Type="Int" />
                            <ColumnModel ID="ColumnModel1" runat="server">
                                    <ext:Column ColumnID="Id" DataIndex="roleId" Hidden="true" Header="Role Id" />
                                    <ext:Column Header="Role Description" DataIndex="roleDesc" Width="600" />
                            <LoadMask ShowMask="true" />
                                <ext:GridFilters runat="server" ID="GridFilters1" Local="true">
                                        <ext:StringFilter DataIndex="roleId" />
                                        <ext:StringFilter DataIndex="roleDesc" />
                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                                <ext:PagingToolbar ID="PagingToolBar1" AutoDoLayout="true" AutoDataBind="true" AutoScroll="false" AutoHeight="false" runat="server" PageSize="8" DisplayInfo="true"
                                     AutoWidth="true" />

  6. #6
    Do you have any JavaScript errors?

    Regarding to:
        Before="return grdRoles.getSelectionModel().hasSelection();">
    Please replace
    return grdRoles.getSelectionModel().hasSelection();
    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, 11:28 AM
  2. Check checkbox in grid
    By reiben in forum 1.x Help
    Replies: 2
    Last Post: Mar 24, 2011, 6:15 PM
  3. Replies: 3
    Last Post: Dec 21, 2010, 3: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, 3:10 PM
  5. How to check if Form or Editable Grid is Dirty ?
    By in forum 1.x Help
    Replies: 1
    Last Post: Aug 31, 2009, 6:03 PM

Posting Permissions