How to disable/enable button based on a value in the grid cell ?

  1. #1

    How to disable/enable button based on a value in the grid cell ?

    I use Ext.net iIn my Index.cshtml page.
    I have a grid and a button called BtnEdit in my page.
    One of the columns in the grid is called "Match".
    I would like to disable BtnEdit when "Match" = "N", and enable it when "Match" = "Y" .
    How can I do that ?
    Thank you.

    This is a snippet of my code:
    @(X.Viewport().Layout(LayoutType.Fit)
                .Items(
                X.GridPanel().ID("GridPanel1").MarginSpec("1 1 1 1").Cls("cust-grid")
                .ColumnModel(
                    X.RowNumbererColumn().Width(35).Sortable(false).Hideable(false),
                    X.NumberColumn().Text("ID").DataIndex("ID").Width(80).Format("#").Align(Alignment.Right).Hideable(false).Groupable(false).Filter(X.NumberFilter()),
    		X.Column().Text("Match").ID("Match").DataIndex("Match").Width(85).Align(Alignment.Center).Hideable(false).Groupable(false).Filter(X.ListFilter().Options("Y,N")),
    	    )		
                .Listeners(ls => ls.Select.Handler = @"var store=App.Store1; var combo=App.NoItem; store.pageSize=combo.getValue(); store.reload();")
                .Plugins(X.GridFilters())
                .View(X.GridView().StripeRows(true).TrackOver(false).GetRowClass(r=>r.Fn="getRowClass"))
                .SelectionModel(X.RowSelectionModel().Mode(SelectionMode.Single))
                .TopBar(
                    X.Toolbar().ID("Toolbar1").MinHeight(35)
                        .Items(
                            X.Button().ID("BtnEdit")
                                .Text("Edit").Icon(Icon.GroupEdit)                            
                                .Handler("var rec=App.GridPanel1.selModel.getSelection()[0]; if(rec) { App.Form1.getForm().loadRecord(rec); App.WindowEdit.show(this);} else alert('Please select row first!')")
    Last edited by faujong; May 02, 2018 at 3:14 PM.

Similar Threads

  1. Replies: 0
    Last Post: Oct 10, 2016, 5:03 PM
  2. [CLOSED] Disable cell editor based on row value
    By susanz in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 08, 2015, 3:52 PM
  3. [CLOSED] Enable/Disable cell or row of a GridPanel
    By timiteh in forum 2.x Legacy Premium Help
    Replies: 12
    Last Post: Mar 21, 2014, 2:56 PM
  4. [CLOSED] Disable/Enable Vertical Marker based on Context Menu
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 21, 2013, 1:44 PM
  5. [CLOSED] Disable/Enable a Grid via it's Toolbar Button ?
    By sisa in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 18, 2013, 1:42 PM

Tags for this Thread

Posting Permissions