joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
74 stars 55 forks source link

Grid in Modal cannot be reloaded. #95

Open Arsaphes opened 7 years ago

Arsaphes commented 7 years ago

Hello,

I open a grid in a modal popup (bootstrap Modal) using the js function modal("show"). Then, after updating or inserting an item, I can't refresh the grid using the function MVCGrid.reloadGrid. The grid is not found. In the dynamic script.js file, the value currentGrids only contains the main web page grid, not the one in the modal.

How can I access my modal grid ? Any option with @Html.MVCGrid() ? Any trouble with the dynamically generated grids ?

Thanks a lot for your help !

joeharrison714 commented 7 years ago

I have not tried displaying the grid in a Modal. Could you send me a SSCCE (http://sscce.org) and I can see if I can help debug.

Arsaphes commented 7 years ago

I've found a solution for that. I noticed that the function 'init' from the 'script.js' file is called each time a page is loaded. Problem is: a modal doesn't call it, and the MVC grid is not in the DOM. So, the MVCGrid doesn't exist in the 'currentGrids' array. I added a function 'reset' that clear the 'currentGrids' array first to avoid adding the main page grid a second time and call the 'init' function. As a matter of fact, I finally have the modal popup grid in the 'currentGrids' array and all the needed interactions. Anyway, thanks very much for the job, it's my favorite grid view !

tqduy commented 6 years ago

How can you add the clear function, @Arsaphes ?