Hi,
Is there a way to switch a radgrid's edit mode from InPlace to BatchEdit client side. My goal is to have a checkbox to enable Batch Editing. When A RadGrid on the page fires the ClientSide OnCommand event, i would like to enter InPlace or BatchEdit EditMode based on whether the checkbox is checked or not. My reasoning for this is that I have multiple RadGrid's on the page that will be controlled by the single checkbox.
Thanks,
Mike
3 Answers, 1 is accepted
Hi Mike,
This would require a postback.
The batch edit mode is very, very different from the InPlace mode and it needs the server to generate certain controls and to fetch scripts.
Regards,
Progress Telerik
Hi,
Thanks for responding. I understand that there will be a postback. My current implementation is as follows: I have a checkbox which the user clicks to enable batch edit mode. On the client side checkChanged event i set a hiddenfield as my flag indicating batch edit is enabled. On the server side check event I switch the radgrid to batch edit and rebind.
My issue with this method is that I have multiple radgrid's on the page where based on the page setup and settings only some are rendered to the client. Because of this, the checkbox is embedded into each radgrid causing each radgrid's batch edit mode to be controlled independently. I would like to abstract this to a single checkbox controlling batch edit mode in all the grids.
I could just handle the checkchanged event server side, and switch all my grids to batch edit mode, but because some are not rendering I need a lot of extra convoluted logic to ensure only the grids rendering are switched to batch edit. Additionally, as settings are changed via partial ajax postbacks and more grids become visible, i need to execute my logic again to ensure all grids are in batch edit mode. Now, because there are multiple settings that could cause a grid to become visible, this logic needs to be implemented in multiple places leading to messy and poor code.
What I would like to do, is set the flag indicating batch edit mode client side. Then, because I have a single method handling my grids client-side onCommand event, that is where i would like to switch to batch edit mode. Sort of lazy initialization, where I would have a flag indicating batch edit is on but only switch the grid to batch edit when an editcommand is raised for the grid.
I may be able to use fireCommand with a custom command, but that again may lead to a whole bunch of extra code. I was hoping there was an internal built in way to do this.
Hi Mike,
You can probably start the grids in batch edit mode and have a flag that cancels the BatchEditOpening event until you are ready to start editing.
Another thing I can suggest you look into is raising a flag in the viewstate, session or as a property of the page class that indicates the edit mode the user wants. Then, if your grids initialize in a common way (e.g., are being created programmatically, or are declared in a user control), you can use a suitable evnet (like the programmatic creation or the Page_Load) to set the desired EditMode based on that flag. Then, if the user changes the checkbox, the form data from the POST query can be used to discern this early in the page lifecycle before the grids initialize so you can have the flag with the correct value upon each postback before each grid initialization.
Yet another approach you can take is to store this user preference in the database and changing it to requier a full page reload - that would be an approach similar to the one above, but will perhaps make it easier on your code as you would check a flag that is more static in nature.
Ultimately, such switching of the edit modes cannot happen client-side only, and it is up to the application logic to determine when and according to what condition the EditMode of the grid is to be set. There are many ways to do that and there is no silver bullet.
Regards,
Progress Telerik