在Ajax调用上刷新Grid.MVC

In my View I have a grid and a checkbox above the grid. On checking the check box I am unable to refresh the grid. I am using Grid.MVC. Can someone help me on this.

Index.cshtml


@(Html.Grid(Model.RequestDetail).Named("RequestGrid").Columns(columns =>
{
    columns.Add(c => c.RequestNumber).Titled("Request Number").Sanitized(false).Encoded(false).RenderValueAs(o => Html.ActionLink(o.RequestNumber, "", new { requestNumber = o.RequestNumber }, new { @class = "anchorDetail" }).ToHtmlString());
    columns.Add(c => c.RequestType).Titled("Request Type");
    columns.Add(c => c.RequestedBy).Titled("Requested By");
    columns.Add(c => c.CreatedDate).Titled("Created").Format("{0:d-MMM-yyyy}");
    columns.Add(c => c.AssignedTo).Titled("Assigned To");
    columns.Add(c => c.DueDate).Titled("Due Date").Format("{0:d-MMM-yyyy}");
    columns.Add(c => c.RequestStatus).Titled("Request Status");
    columns.Add(c => c.CompletedDate).Titled("Completed Date").Format("{0:d-MMM-yyyy}");
}).WithPaging(10).Sortable())

Script:

function ViewAssignedRequests() {
            var userName = "@ViewData["Name"]";
            var isChecked;
            if (document.getElementById('chkAssign').checked) {
                isChecked = true;
            }
            else {
                isChecked = false;
            }
            $.ajax({
                type: "POST",
                url: "/ViewRequestDetails/GetAssignedList",
                contentType: "application/json; charset=utf-8",
                data: "{ 'userName' : '" + userName + "', 'isChecked' : '" + isChecked + "' }",
                datatype: "json",
                success: function () {
                    $('.grid-mvc').gridmvc();
                    $('#RequestGrid').reload();
                    //pageGrids.RequestGrid.refreshFullGrid();
                },
                error: function () {
                    alert("Dynamic content load failed.");
                }
            });
        }

My controller is directly returning the entire view

[HttpPost]
        public ActionResult GetAssignedList(string userName, bool isChecked)
        {
            RequestDetails reqObj = new RequestDetails();
            reqObj.RequestDetail = viewDAObj.PopulateRequestAssignedGrid(userName, isChecked);
            return View("Index", reqObj);
        }
查看全部
weixin_33743248
weixin_33743248
2017/12/19 06:54
  • ajax
  • 点赞
  • 收藏
  • 回答
    私信

0个回复