This is a migrated thread and some comments may be shown as answers.

AutoBind question

1 Answer 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt Bowser
Top achievements
Rank 1
Veteran
Matt Bowser asked on 15 Dec 2020, 02:15 AM

I have a grid that is loading in a modal popup (a partial view) that requires some information from the parent page being set before calling the datasource on the controller.  I have set AutoBind to false and while it does prevent the datasource from calling the controller until I load the partial view, the .Data(javascript function) that builds the dataset needed for the controller is still being hit as soon as the parent page is initialized, but before the values on the page have been set (user input fields).  

Is there a way to either prevent this from happening, or is there another technique I should be using?

Thanks for any help in advance

 

 

1 Answer, 1 is accepted

Sort by
0
Matt Bowser
Top achievements
Rank 1
Veteran
answered on 15 Dec 2020, 03:18 PM
Ok, I solved it and as usual I WAY overthought it.  It didn't occur to me that the grid.datasource.read() function within the javascript call could pass parameters.
Before: Calling without updated date parameter

function assignAgent(Id) {
        var date = setDate(setCoEId().coeId).dayOfWeek;
        var grid = $('#assignAgentGrid').data("kendoGrid");
        grid.dataSource.read();
    }

After: Calling with updated parameter

function assignAgent(Id) {
        var date = setDate(setCoEId().coeId).dayOfWeek;
        var grid = $('#assignAgentGrid').data("kendoGrid");
        grid.dataSource.read({ dayOfWeek: date });
    }
Tags
Grid
Asked by
Matt Bowser
Top achievements
Rank 1
Veteran
Answers by
Matt Bowser
Top achievements
Rank 1
Veteran
Share this question
or