Reputation: 1187
I have my webgrid in a partial page as follows. From the following page I updates my grid in a partial view, through an ajax call.
@using (Html.BeginForm("Manage", "Book",FormMethod.Get, new { @id = "frmBGrid" }))
{
<fieldset id="form">
<div>
<select id="BookType" name="BookType">
@*<option value=""></option>*@
<option selected="selected" value="0">View All</option>
<option value="1">View New</option>
<option value="2">View Published</option>
</select>
</div>
<div id="BookGridid">
@{
@Html.Partial("_BookGridList", Model)
}
</div>
</fieldset>
}
And My Ajax inside my drop down change, where I pass the selected drop-down value to the controller. And updates the grid based on the returned model.
var SelectedValue = $('#BookType').val();
$.ajax({
type: "POST",
url: href,
dataType: "html",
traditional: true,
contentType: 'application/json',
data: JSON.stringify({ bookType: SelectedValue }),
success: function (returndata) {
$('#BookGridid').html(returndata);
},
complete: function (xhr, status) {
},
error: function (arg, data, value) {
}
});
From my controller based on the parameter I will send back the Model list to bind to the webgrid.
However the problem is on pagination or sorting, I am unable to pass the selected drop down value. How can i achieve that?
Upvotes: 2
Views: 510
Reputation: 1187
Stored the Filtration Value in a session. Hence for Pagination also used that filtered value.
Upvotes: 1