0

このチュートリアルhttp://haacked.com/archive/2009/04/13/using-jquery-grid-with-asp.net-のアプローチに従って、コントローラーから情報を取得する JQGrid を実装しようとしています。mvc.aspx

私のコントローラーのコードは次のとおりです。

    public ActionResult GridData(string sidx, string sord, int page, int rows)
    {
        var jsonData = new
        {
            total = 1,  
            page = page,
            records = 1, 
            rows = new[]
            {
                new {id = 1, cell = new[] {"", "", "", "", "", "", "f", "", "", "", "",     "", "", ""}},
            }
        };
        return Json(jsonData, JsonRequestBehavior.AllowGet);
    }

私のビューのコードは次のとおりです。

<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-    1.8.23.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.multiselect.css" />

<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>

<script type="text/javascript">
jQuery(document).ready(function ()
{
    jQuery("#list").jqGrid(
        {
            url: '/WebFormUserList/GridData',
            datatype: 'json',
            mtype: 'GET',
            colNames:
                [
                    'User_ID', 'Forename', 'Surname', 'Client_Code', 'User_Name',
                    'Password', 'Email', 'Gender', 'Report_Date', 'Email_Date',
                    'Test_Count', 'Test_Completed', 'Job_Function', 'Lookup_Value'
                ],
            colModel:
                [
                    { name: 'User_ID', index: 'User_ID', width: 'auto', align: 'centre' },
                    { name: 'Forename', index: 'Forename', width: 'auto', align: 'centre' },
                    { name: 'Surname', index: 'Surname', width: 'auto', align: 'centre' },
                    { name: 'Client_Code', index: 'Client_Code', width: 'auto', align: 'centre' },
                    { name: 'User_Name', index: 'User_Name', width: 'auto', align: 'centre' },
                    { name: 'Password', index: 'Password', width: 'auto', align: 'centre' },
                    { name: 'Email', index: 'Email', width: 'auto', align: 'centre' },
                    { name: 'Gender', index: 'Gender', width: 'auto', align: 'centre' },
                    { name: 'Report_Date', index: 'Report_Date', width: 'auto', align: 'centre' },
                    { name: 'Email_Date', index: 'Email_Date', width: 'auto', align: 'centre' },
                    { name: 'Test_Count', index: 'Test_Count', width: 'auto', align: 'centre' },
                    { name: 'Test_Completed', index: 'Test_Completed', width: 'auto', align: 'centre' },
                    { name: 'Job_Function', index: 'Job_Function', width: 'auto', align: 'centre' },
                    { name: 'Lookup_Value', index: 'Lookup_Value', width: 'auto', align: 'centre' },
                ],

            pager: jQuery('#pager'),
            height: 'auto',
            width: 1000,
            rowNum: 10,
            rowList: [5, 10, 20, 50],
            sortname: 'Id',
            sortorder: "desc",
            viewrecords: true,
            imgpath: '/css/ui-lightness/images',
            caption: 'My first grid'
        });
});

グリッドのページを呼び出そうとすると、以下のエラーが発生します。

パラメーター ディクショナリには、'HFI_Assessment_Administration のメソッド 'System.Web.Mvc.ActionResult GridData(System.String, System.String, Int32, Int32)' の null 非許容型 'System.Int32' のパラメーター 'page' の null エントリが含まれています.Controllers.WebFormUserListController'. オプションのパラメーターは、参照型または null 許容型であるか、オプションのパラメーターとして宣言する必要があります。パラメータ名: パラメータ

人々が提供できる助けやアドバイスをいただければ幸いです。誰かがsidx、sord、page、rowsがどのように渡されるかを説明できれば、それも私の理解に大いに役立ちます。

どうもありがとう!

4

1 に答える 1

0

pageあなたの例では初期化されていません。これを試して:

        page  = 1,
        records = 1, 
        rows = new[]
        {
            new {id = 1, cell = new[] {"", "", "", "", "", "", "f", "", "", "", "",     "", "", ""}},
        }
于 2012-09-25T15:54:08.763 に答える