组合框过滤后执行后退网格视图

时间:2016-04-01 02:35:38

标签: javascript asp.net-mvc-4 gridview combobox devexpress

你可以帮我修复我的问题,我做了gridview,我使用组合框来过滤gridview中的数据,并在过滤后得到gridview performcallback,但gridview不会在过滤后回调。我能怎么做 ?请帮帮我? 这是一些代码: 控制器gridview过滤器:

        [HttpPost]
        public ActionResult FilterTypePro(String typePro)
        {
            //Session["typePro"] = typePro;
            var model = Model._ProposalObject.ListDataProposal();

            if (typePro != null && typePro != string.Empty)
            {
                model = Model._ProposalObject.ListDataProposal(typePro);
            }

            return PartialView("_gvPartialViewProposals", model);
        }

这是获取值过滤器组合框的代码:

    function OnClickFilter(type) {
        type = cbTypeProposal.GetValue();     
        $.ajax({
            type: "POST",
            cache: false,
            async: false,
            url: '@Url.Action("FilterTypePro", "App")',
            data: { 'typePro': type },
            success: function (data) {
                /*gvPartialViewProposals.AdjustControl();
                try {
                    gvPartialViewProposals.PerformCallback();
                }
                catch(er){
                }*/
                gvPartialViewProposals.Refresh(data);
            }
        });
    }

这是查看cshtml的代码:

groupItem.Items.Add(item =>
            {
                    item.Caption = "Type Of Proposal";
                    item.Width = 400;
                    item.SetNestedContent(() =>
                    {
                        ViewContext.Writer.Write("<table><tr><td>");
                        Html.DevExpress().ComboBox(cmbSettings =>
                        {
                            cmbSettings.Name = "cbTypeProposal";
                            cmbSettings.Width = 100;
                            cmbSettings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                            cmbSettings.ShowModelErrors = true;
                            cmbSettings.Properties.Items.Add("ATL", "ATL");
                            cmbSettings.Properties.Items.Add("BTL", "BTL");
                            cmbSettings.Properties.ClientSideEvents.SelectedIndexChanged = "function(s, e) { OnClickFilter();}";
                        }).Render();
                        ViewContext.Writer.Write("</td></tr></table>");
                    });
                }); ;
        }).GetHtml();

我希望你能帮助我。

1 个答案:

答案 0 :(得分:1)

修改您的javascript函数,如下所示:

function OnClickFilter(type){
    type = cbTypeProposal.GetValue(); 
    gvPartialViewProposals.PerformCallback({
        'typePro': type
    });
} 

按如下方式修改网格设置:

settings.Name = "gvPartialViewProposals";
settings.CustomActionRouteValues = new { Controller = "App", Action = "FilerTypePro" };