This is a migrated thread and some comments may be shown as answers.

[Solved] MVC Telerik Grid values on sorting and paging

0 Answers 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Shivprasad
Top achievements
Rank 1
Shivprasad asked on 13 Jun 2011, 04:33 PM
I have Textbox, search button and MVC telerik Grid on a page. On Click on button the button, I am getting textbox value in My ActionMethod and based on this textbox value, I am feting the records and displaying in Grid. But as I am try to sort, or click on paging link it, It gives to call to Ajax method which again resetting the Grid values and loosing the previous values. Could anybody please let me know how to maintain the state of textbox and grid as well?

Please find the code below.

View Code:

 
@ using (Html.BeginForm("Index", "Home")) 
{
    @Html.TextBox("txtStudentName")
<button class="t-button" name="buttonName" type="submit" value="search">Search</button>
}
  
   
@( Html.Telerik().Grid(Model)
.Name("Grid"
.Pageable(paging => paging 
.PageSize(10)
.Style( GridPagerStyles .NextPreviousAndNumeric) 
.Position( GridPagerPosition.Bottom)) 
Sortable(sorting => sorting
.SortMode(GridSortMode.SingleColumn)) 
.Filterable(filtering => filtering.Enabled(true))
.Scrollable(scrollable => scrollable.Enabled(true)) 
.Selectable()
.Columns(columns => 
{
columns.Bound(o => o.StudentID).Title("ID"); 
columns.Bound(o => o.StudentName).Title("Name"); 
})
.DataBinding(dataBinding =>
{ dataBinding.Ajax().Select("_AjaxBinding", "Home");
})
)
  
Controller Code
public ActionResult Index(string txtStudentName)
{
    Based on txtStudentName, I am fetching the records
    or setting initially to default values.
}

[GridAction
public ActionResult _AjaxBinding( 
{
 return View(new GridModel.......
}

 

 

 

 

 

 

How to solve this problem.  Please Help.



 

 

 

 

Tags
Grid
Asked by
Shivprasad
Top achievements
Rank 1
Share this question
or