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
115
Changing "multipleSelection"-Option after rendering
posted

I have a MVC-Grid like

@(Html.Infragistics()
   .Grid(Model)
   .ID("GridResults")
   .Width("100%")
   .Height("300px")
   .PrimaryKey("Value")
   .AutoGenerateColumns(false)
   .AutoGenerateLayouts(false)
   .AutoAdjustHeight(false)
   .Columns(column =>
   {
       column.For(x => x.Type).HeaderText("Typ").Width("3%").DataType("string");
       column.For(x => x.Name).HeaderText("Name").Width("85%").DataType("string");
   })
   .Features(features =>
   {
       features.Sorting().Type(OpType.Remote);
       features.Paging().Type(OpType.Remote).PageSize(25);
       features.Filtering().Type(OpType.Remote);
       features.Selection().Mode(SelectionMode.Row).MultipleSelection(true);
       features.RowSelectors().EnableCheckBoxes(true).EnableRowNumbering(false);
   })
   .Render()

I'm setting the datasourceUrl after Click-Event in the Website
...
var gridResult = $('#GridResults');
var url = '...';
gridResult.igGrid('option''dataSource', url);
gridResult.igGrid('dataBind');

Thats working fine.
But now i like to change the multiple selection behaviour in the click-event:
var multiSelect = gridResult.igGridSelection('option''multipleSelection');
if (multiSelect === true) {
    gridResult.igGridSelection('option''multipleSelection'false);
}
...
gridResult.igGrid('option''dataSource', url); gridResult.igGrid('dataBind');

After i asked the status again, i got correct value of "false",
but i can still select (checkbox) more than one row in the grid.

Whats wrong?
  • 5513
    Verified Answer
    Offline posted

    Hello Michael,

    Changing the multipleSelection option at runtime is currently not supported. The control should throw an exception in this case but it doesn't and we will need to fix it.

    Usually the workaround for such issues is to destroy and recreate the grid with the new setting, however, when using the MVC wrappers the cleanest solution would be for the button to call a controller that returns a view which initializes the grid with the changed option. If this is undesirable, you could also go through the widgets initialized on the grid's element and get the options they are initialized with, then create an options object that you could create the same grid with entirely on the client side.

    If you need help with either approach, please let me know so I can prepare a small sample demonstrating it.

    Best regards,

    Stamen Stoychev