AutoBind question

2 posts, 0 answers
  1. Matt Bowser
    Matt Bowser avatar
    8 posts
    Member since:
    Sep 2006

    Posted 14 Dec 2020 Link to this post

    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

     

     

  2. Matt Bowser
    Matt Bowser avatar
    8 posts
    Member since:
    Sep 2006

    Posted 15 Dec 2020 in reply to Matt Bowser Link to this post

    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 });
        }
Back to Top