Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / Set entire grid "disabled" or "readonly"

Set entire grid "disabled" or "readonly"

New Discussion
Josh
Josh asked on May 30, 2012 11:07 PM

How do you set an entire grid to “disabled” or “readonly” in javascript?

I looked at the docs but didn’t see any options or methods to do so:

http://help.infragistics.com/jQuery/2011.2/ui.iggrid

Sign In to post a reply

Replies

  • 0
    Ugo Bellucci
    Ugo Bellucci answered on May 24, 2012 2:07 PM

    Hi, have you tried this?

    //Initialize

    $("#grid").igGrid({

        features: [

    {

    name: "Updating",

    editMode: "none",

    enableAddRow: false,

    enableDeleteRow: false

            }    ]});

    //Set

    $("#grid").igGridUpdating("option", "editMode", "none");

    $("#grid").igGridUpdating("option", "enableDeleteRow", false);

    $("#grid").igGridUpdating("option", "enableAddRow", false);

    • 0
      Josh
      Josh answered on May 24, 2012 3:13 PM

      Thanks, but this isn't exactly what I'm looking for.  Sorry, should have been more specific.  What I want is something like a regular html control's "Readonly" or "Disabled" attribute, where the control is completely uneditable and indicates this visually (in most cases they're "greyed out").

      In the case of the IgGrid, I would want the user to be unable to make any selections, sort, or use any of the other Grid functionality.

      I should also mention that my grid is generated from the MVC Helper, just in case there are inconsistencies between this and the client-side generation.

      • 0
        [Infragistics] Borislav Traykov
        [Infragistics] Borislav Traykov answered on May 25, 2012 9:32 PM

        Hi Josh,

        The most consistent approach I can think of and I can recommend is to cancel the ING events of the features you have set up on the igGrid.
        For example, you can cancel the columnSorting event of the sorting feature – that way the sorting feature is present, but no sorting will be carried out until the event handler you've set up returns true.

        Let me back up a little and start off with this help article:
        http://help.infragistics.com/NetAdvantage/jQuery/2012.1/CLR4.0?page=Using_Events_in_NetAdvantage_for_jQuery.html

        It will help you understand how to hook event handlers to the igGrid that you've set up via MVC.

        Next is the mention that if you take a look at the sorting feature's events for example (http://help.infragistics.com/jQuery/2012.1/ui.iggridsorting#events) you will see that:

        • a lot of them come in pairs (like columnSorting and columnSorted)
        • some of them are "cancellable" (99% of the -ing events are:))

        Finally, another point of reference is the Samples Browser – just go to http://samples.infragistics.com/jquery/grid and expand the FEATURES LIST item in the left-side menu.
        There you will see a search field – type in "API" in it and you will receive a list of API-related samples for the igGrid – all of them show both the sample-specific API, but a set of events as well.
        For example:
        http://samples.infragistics.com/jquery/grid/sorting-api and http://samples.infragistics.com/jquery/grid/selection-api

        You can take a look at the code samples in the Code View section of these samples – there you will see event handlers that are used in each sample.

        Finally, the last upside to this approach is that if you are using a "readonly flag", you can simply return it in each -ing event handler so that when that flag becomes true, the user will automatically be able to use the grid's feature(s).

        As comprehensive as this reply may be, please let me know if there are any uncertainties or clarifications that you need to get accomplish your scenario with the igGrid.

        Cheers!
        Borislav

      • 0
        Josh
        Josh answered on May 30, 2012 11:07 PM

        Thanks Borislav!  This works perfectly.  It's a shame there's not a built-in 'readonly' method, but this was pretty straight-forward.

        Just wanted to add that anyone who wants to do this should probably namespace the event handling.  Then, when you unbind the "cancelling" handlers when readonly is set to false, you won't unbind any other handlers attached to these events.

        http://docs.jquery.com/Namespaced_Events

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Josh
Favorites
0
Replies
4
Created On
May 30, 2012
Last Post
13 years, 9 months ago

Suggested Discussions

Tags

Created by

Created on

May 30, 2012 11:07 PM

Last activity on

Feb 25, 2026 10:32 AM