jqgrid url没有调用控制器动作方法mvc3

时间:2013-09-03 18:40:13

标签: asp.net-mvc jqgrid

我想从我的jqgrid调用一个控制器动作,为此我使用了jqgrid的url属性,但仍然没有调用控制器动作方法....正在加载jqgrid但没有任何数据,发布我的视图,任何人都可以指出哪里出了问题

<link href="../../Content/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/start/jquery-ui.css" rel="Stylesheet" type="text/css" />
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../Scripts/grid.locale-en.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.maskedinput-1.2.2.min.js" type="text/javascript"></script>




     $(document).ready(function () {

     var updateDialog = {

     url: "/Contact/Update"
            , closeAfterAdd: true
            , closeAfterEdit: true
            , afterShowForm: function (formId) {
                $("#PhoneNumber").mask("(999) 999-9999");
                $("#DateOfBirth").datepicker();
            }
            , afterclickPgButtons: function (whichbutton, formid, rowid) {
                $("#PhoneNumber").mask("(999) 999-9999");
            }
            , modal: true

            , onclickSubmit: function (params) {
                var ajaxData = {};

                var list = $("#list");
                var selectedRow = list.getGridParam("selrow");
                rowData = list.getRowData(selectedRow);
                ajaxData = { ContactId: rowData.ContactId };

                return ajaxData;
            }

            , width: "400"
     };
     $.jgrid.nav.addtext = "Add";
     $.jgrid.nav.edittext = "Edit";
     $.jgrid.nav.deltext = "Delete";
     $.jgrid.edit.addCaption = "Add Contact";
     $.jgrid.edit.editCaption = "Edit Contact";
     $.jgrid.del.caption = "Delete Contact";
     $.jgrid.del.msg = "Delete selected Contact?";
     $("#list").jqGrid({
         url: "/List/Contact/",
         datatype: 'json',
         mtype: 'GET',
         colNames: ['ContactId', 'Name', 'Date of Birth', 'E-mail', 'Phone Number', 'Married'],
         colModel: [
                { name: 'ContactId', index: 'ContactId', width: 40, align: 'left', /* key: true,*/editable: true, editrules: { edithidden: false }, hidedlg: true, hidden: true },
                { name: 'Name', index: 'Name', width: 300, align: 'left', editable: true, edittype: 'text', editrules: { required: true }, formoptions: { elmsuffix: ' *'} },
                { name: 'DateOfBirth', index: 'DateOfBirth', width: 200, align: 'left', formatter: 'date', datefmt: 'm/d/Y', editable: true, edittype: 'text', editrules: { required: true, date: true }, formoptions: { elmsuffix: ' *'} },
                { name: 'Email', index: 'Email', width: 200, align: 'left', formatter: 'mail', editable: true, edittype: 'text', editrules: { required: true, email: true }, formoptions: { elmsuffix: ' *'} },
                { name: 'PhoneNumber', index: 'PhoneNumber', width: 200, align: 'left', editable: true, edittype: 'text', editrules: { required: true, custom: true, custom_func: isValidPhone }, formoptions: { elmsuffix: ' *'} },
                { name: 'IsMarried', index: 'IsMarried', width: 200, align: 'left', editable: true, edittype: 'checkbox', editoptions: { value: "True:False" }, editrules: { required: true}}],
         pager: $('#listPager'),
         rowNum: 1000,
         rowList: [1000],
         sortname: 'ContactId',
         sortorder: "desc",
         viewrecords: true,
         imgpath: '/Content/Themes/Redmond/Images',
         caption: 'Contact List',
         autowidth: true,
         ondblClickRow: function (rowid, iRow, iCol, e) {
             $("#list").editGridRow(rowid, prmGridDialog);
         }
     }).navGrid('#listPager',
            {
                edit: true, add: true, del: true, search: false, refresh: true
            },
            updateDialog,
            updateDialog,
            updateDialog
        );
 });       
</script>

//My Action Method 
public ActionResult Update(ContactViewModel viewModel, FormCollection formCollection)
{
 return Content(repository.HasErrors.ToString().ToLower()); 

}

0 个答案:

没有答案