[CLOSED] Grid panel selected row cout check-MVC

  1. #1

    [CLOSED] Grid panel selected row cout check-MVC

    I have a grid panel

    <script>
        Ext.onReady(function () {
           // Ext.getCmp("btnEdit").setDisabled(true);
        });
        /* A header Checkbox of CheckboxSelectionModel deals with the current page only.
        This override demonstrates how to take into account all the pages.
        It works with local paging only. It is not going to work with remote paging.
        */
        Ext.selection.CheckboxModel.override({
            selectAll: function (suppressEvent) {
                var me = this,
                selections = me.store.getAllRange(), // instead of the getRange call
                i = 0,
                len = selections.length,
                start = me.getSelection().length;
                me.suspendChanges();
                for (; i < len; i++) {
                    me.doSelect(selections[i], true, suppressEvent);
                }
                me.resumeChanges();
                if (!suppressEvent) {
                    me.maybeFireSelectionChange(me.getSelection().length !== start);
                }
            },
            deselectAll: Ext.Function.createSequence(Ext.selection.CheckboxModel.prototype.deselectAll, function () {
                this.view.panel.getSelectionMemory().clearMemory();
            }),
        });
    </script>


     Html.X().GridPanel()
    .ID("GridPanel1")
    .Title("Tasks")
    .Frame(true)
    .Layout("fit")
    .Store(
    Html.X().Store()
    .ID("Store1")
    .Model(
    Html.X().Model()
     .IDProperty("MaterialCatergoryID")
    .Fields(
    
    Html.X().ModelField().Name("IsActive").Type(ModelFieldType.Boolean),
    
    Html.X().ModelField().Name("CategoryName").Type(ModelFieldType.String)
    
    )
    )
     .DataSource(ViewBag.loadgrid)
    .PageSize(10)
    )
    .ColumnModel(
     Html.X().Column()
    .DataIndex("IsActive")
    .Text("IsActive")
    .Flex(1),
     Html.X().Column()
    .DataIndex("CategoryName")
    .Text("CategoryName")
    .Flex(1)
    )
     .SelectionModel(
    X.CheckboxSelectionModel()
    .ID("s")
    .Mode(SelectionMode.Multi)
    )
    .Plugins(
        Html.X().CellEditing()
    )
    .BottomBar(
    Html.X().PagingToolbar()
    .HideRefresh(true)
    )
    .TopBar(
    Html.X().Toolbar()
    .Items(
    Html.X().TextField()
    .ID("txtSearch")
    .EmptyText("Search by Module name")
    .DirectEvents(de =>
    {
        de.Change.Action = "/search";
        de.Change.ExtraParams.Add(new Parameter
        {
            Name = "data",
            Value = "Ext.getCmp('txtSearch').getValue()",
            Mode = ParameterMode.Value,
            Encode = false
        }
        );
    })
    ,
    How do i do?If only one row is selected then only edit button is enable other wise the button is disable.

    live example here
    http://legalinfoservices.com/home
    Purchase Management->Master Management->Material Category
    Last edited by Daniil; Jun 17, 2014 at 11:41 AM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    I think for initial state you can set
     .Disabled(true)
    for the Button, because there is probably no selection.

    Then I would listen to a CheckboxSelectionModel's SelectionChange event.
    http://docs.sencha.com/extjs/4.2.1/#...electionchange

    As you can see there is the "selected" argument. It is an array of selected records. You can check length of that array and enable or disable the Button accordingly.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @matrixwebtech,

    I think for initial state you can set
     .Disabled(true)
    for the Button, because there is probably no selection.

    Then I would listen to a CheckboxSelectionModel's SelectionChange event.
    http://docs.sencha.com/extjs/4.2.1/#...electionchange

    As you can see there is the "selected" argument. It is an array of selected records. You can check length of that array and enable or disable the Button accordingly.
    Daniil,
    Thanks for your reply.
    But I am very new with EXT.NET so I am not understand how to implement the script which you provide.
    I attach a screen shot and try to describe what I actually need.There are 2 records in grid,I want when only 1 row is selected then only the edit button is enable.but there are another logic,
    The Logic Is
    By default Edit Button is disable ,If only 1 row is selected and Edit Button "Disabled" Property set to FALSE then only the Edit Button get Enable other wise Disable.
    Attached Thumbnails 11.png  
  4. #4
    I suggest to read this about this tutorial about client side events. After reading you should be able to use Listeners.
    http://www.ext.net/2012/12/19/introd...xt-net-events/

Similar Threads

  1. Replies: 2
    Last Post: Sep 12, 2012, 10:28 AM
  2. How to get values from grid panel selected row
    By mehmood in forum 1.x Help
    Replies: 9
    Last Post: Apr 11, 2012, 12:09 PM
  3. Replies: 1
    Last Post: Mar 11, 2012, 3:26 AM
  4. Replies: 6
    Last Post: Sep 21, 2011, 9:37 AM
  5. Replies: 0
    Last Post: Jan 28, 2010, 2:47 AM

Tags for this Thread

Posting Permissions