Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 27, 2012 11:16 AM by asteranup
Apr 27, 2012 09:38 AM|LINK
Im currently working on an MVC applicaiton that performs a sequence of steps listed below.
1. User performs a search from the search page which results in the action Search being invoked in the SearchController.
2. The Search action performs filtering and renders the search data in the Search.cshtml (This view supports edit over the searched results.)
3. When the user clicks on the edit link, the Edit action is invoked in the EditController.
4. The Edit action selects the record and renders it in the Edit.cshtml. (This view supports Save and Cancel.)
So heres the question. Within the Edit.cshtml if the user clicks Cancel, the application should show the filterd results back. The issue is passing the filter critera back from the Edit.cshtml to the SearchController's Search action. The point being that
Edit.cshtml would not have any idea about parameters/filter criteria that was passed when the initial search was performed.
Based on your experience what would be the best mechanisum to store the filter criteria (which is a view-model object) in such a senario?
Apr 27, 2012 11:02 AM|LINK
save it in hidden fields in page or render it into json object. bind it to model in controller action
hope this helps
Apr 27, 2012 11:16 AM|LINK
I think what you can do is build a ajax based approach.
Have a main view say index. Have three divs one below other first for the search criteria and search button, second for grid, and third for edit.
Put your search criteria first section. Implement ajax form in the first section and give the target control to the second div. This will display the content of the result in the second div. Now if you want to hide the search criteria. You can write a script
in the search result view to hide the first div. Now on click of a row in the table implement an ajax action link with target as third div. Same like in result div, if you want to hide the result while editing, add a script in the edit view to hide the result