1

Get、Edit、およびDeleteはすべて正常に機能します。ただし、addはActionResultメソッドを呼び出しません。新しいレコード値のモーダルフォームを表示するインライン追加を使用しています。最新のjqGridリリースで提供されているpager/formメソッドでこれがどのように機能するかの例はほとんどないようです。ここに追加/挿入するために何が欠けていますか?

html:

            $("#grid").jqGrid({
                url: 'ABC.Admin/CourseAdmin/GetLocationData/',
                datatype: 'json',
                jsonReader: { repeatitems: false },
                mtype: 'GET',
                colNames: ['Location Id', 'Name', 'Address Line 1'],
                colModel: [
              { name: 'LocationId', index: 'LocationId', width: 40, key: true },
              { name: 'LocationName', index: 'LocationName', width: 150, editable: true },
              { name: 'AddressLine1', index: 'AddressLine1', width: 150, editable: true },
              ],
                pager: jQuery('#pager'),
                rowNum: 20,
                sortname: 'Name',
                sortorder: "asc",
                viewrecords: true,
                caption: '***Testing***',
                height: 200,
                loadonce: true, // needs to be true for client side paging to work
                autowidth: true,
                loadtext: 'Loading...'
            })
            $("#grid").jqGrid('navGrid', '#pager', { edit: true, add: true, del: true },
            { // edit options 
                url: 'ABC.Admin/CourseAdmin/SaveLocation/',
                closeAfterEdit: true
            },
            { // add
                url: 'ABC.Admin/CourseAdmin/Create/'
            },
            { //delete
                url: 'ABC.Admin/CourseAdmin/DeleteLocation/',
                closeOnEscape: true
            }
        );

コントローラ:

public ActionResult Create(int id、string locationName、string addressLine1)

[HttpPost]
public ActionResult CreateLocation(string oper, string id, string locationName, string addressLine1)        {
            //Models.LocationProvider lp = new Models.LocationProvider();
            //bool saved = lp.InsertLocation(location);
            bool saved = false;
            if (!saved)
            {
                Response.StatusCode = 500;
                return Content("Record not saved!");
            }
            else
            {
                return Json(false);
            }
        }
4

1 に答える 1

0

私はそれを解決しました。Create メソッド sig のパラメーターの型が一致しませんでした。それらはすべて文字列である必要があります。コントローラーを次のように変更すると機能します。また、 idoperパラメーターは順序ではなく名前で取得されることに気付きました。そのため、署名の最初または最後 (または任意の場所) に配置すると、正しい値が取得されます。クールです! この修正で元の投稿を編集します。

        public ActionResult Create(string oper, string id, string locationName, string addressLine1)

jqGridの追加/挿入の例を探している他の人にとって、これが役立つことを願っています.

于 2012-05-05T21:48:59.923 に答える