Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
160
Anyway to toggle grid features?
posted

Is there any way to enable and disable features of the grid from a button click? For instance we have a need to only allow edit mode when a button is clicked and once all edits are completed the user would click save and return to a normal grid.

We would like to use this functionality with filtering, groupby, and edit mode.

Based on the documentation it says all features must be set when the grid is instantiated, so short of destroying and recreating the grid I do not see any other way of doing this.

Thanks in advance,

Joshua

Parents
No Data
Reply
  • 24671
    Verified Answer
    posted

    Hi,

    it really depends on the feature. i would suggest not to do this unless you re-create the grid widget. i can give you an example. GroupBy attaches its functionality on header cells, but header cells are not  re-rendered unless the grid is recreated. I mean when you rebind the grid, only the data gets rebind, so even if you re-instantiate the feature, this functionality will not be attached to header cells. 

    Other than that, this is the way to destroy and then create a grid feature:

    two buttons:

    <input type="button" value="Destroy Feature" onclick="destroyGroupBy();"/>

    <input type="button" value="Create Feature" onclick="createGroupBy();"/>

    function destroyGroupBy() {

    $("#table1").igGridGroupBy("destroy");

    }

    function createGroupBy() {

    var grid = $("#table1").data("igGrid");

    $("#table1").igGridGroupBy(grid.options.features[0]); // replace 0 with the index of your feature in the features collection. this is necessary so that initial options are passed again

    grid.dataBind();

    }

    But again, this may only work for some features, if the grid is not re-created. all features listen to grid events in order to attach their logic. so for example, groupby listens to gridRendereing, in order to add its special groupby area on top of the grid header. it also listens to headerrendered, in order to decorate header cells so that they become draggable. if the grid isn't destroyed & created again, this won't work.

    Hope it helps. Thanks,

    Angel

Children
No Data