This project is read-only.

Click sort button and disappear data

Jun 3, 2015 at 10:36 AM
Edited Jun 3, 2015 at 11:32 AM
I 'm new in MVC web programming and MVC grid.
My page is contained search criteria. If I click submit button data shows in grid. It works fine. But if I click sort link on grid header page is refreshed and data is disappeared(in grid --> 'There are no items to display')
TestController.cs
    public class TestController : Controller
    {
        public ActionResult GridTest()
        {
     
            return View();
        }

        [HttpPost]
        public ActionResult GridTest(FilterModel model)
        {
            return View(model);
            
        }

        public PartialViewResult Grid2(FilterModel filter)
        {
            List<CarModel> carModels = new List<CarModel> { new CarModel { Name = "Volvo", Id = 1 }, new CarModel { Name = "Saab", Id = 1 }, new CarModel { Name = "Mercedes", Id = 3 } };
            var t  = carModels.Where(p => p.Id == filter.MinId).ToList();
            filter.personList = t;
            return PartialView(filter);
        }
    }
Grid2.cshtml
@using GridMvc.Html
@model MVCGridDenemesi1.Models.FilterModel

@Html.Grid(@Model.personList).Columns(columns =>
{
    columns.Add(car => car.Name).Titled("Car").Sortable(true);
    columns.Add(car => car.Id).Titled("Id");

})
GridTest.cshtml:
@model MVCGridDenemesi1.Models.FilterModel

@using (Html.BeginForm("GridTest", "Test", FormMethod.Post))
{
    <div class="form-group">
        @Html.LabelFor(m => m.MinId, new { @class = "col-sm-2 control-label" })
        <div class="col-sm-10 selectContainer">
            @Html.TextBoxFor(m => m.MinId, new { @id = "finishFolderNo", @class = "form-control" })
            @Html.ValidationMessageFor(m => m.MinId)
        </div>
    </div>

    <div id="Grid2">
        @{
    Html.RenderAction("Grid2", Model);
        }
    </div>

    <input type="submit" value="Sorgula" />
    
}


@section Scripts
{
    <script type="text/javascript">
        function success(result) {
            if (result.IsSuccess) {

            }
        }
    </script>
}
if I set Model into Session in Gridtest.cshtml and get from session in controller(GridTest() method) it works fine. But I dont want to use Session.
Thanks for any advice
Jun 3, 2015 at 12:23 PM
Edited Jun 3, 2015 at 12:25 PM
please help
Mar 27, 2016 at 1:27 PM
Hi,

How did you solve this problem? I am having the same problem.

Thanks you.
Maitri.
Mar 27, 2016 at 2:14 PM
Edited Mar 28, 2016 at 7:53 AM
I have converted it to Jtable