Reputation: 306
When I click on the "Add" button of a grid, the page is redirected to a new view (with "new" and the user signature as arguments) with an Add form created by the grid.
I want the Add form to instead appear in the same view with the grid, on top of the grid, if someone clicks the "Add" button (i.e there is "new" in request.args), and to disappear when the submit or back buttons are clicked.
My current approach is to show a custom insert form that appears when an "Add" button is clicked, But I would prefer to use the grid for this.
How can I do it?
Upvotes: 1
Views: 1249
Reputation: 25536
One option might be to load the grid via an ajax component. Then add some Javascript to the page that intercepts the clicking of the "Add" button (which you can identify via its "buttonadd" class). The Javascript should then load the "add" URL into another ajax component, which will present the create form. You could add some additional logic so that when the create form has been submitted, it's component div can be hidden, and you might also consider refreshing the grid div so the grid will include the new record.
Upvotes: 1