0

如何在 jqgrid 中对弹出对话框进行编辑。

下面是jqgrid的东西。我不需要内联编辑。我想弹出对话框。要弹出对话框,我们已经有了可以弹出的对话框。为此,我需要调用 - 可以允许弹出对话框的 javascript 函数。请指导我如何在单击编辑图标时调用 javascript 函数?

      $('#CategoriesGrdList').jqGrid({
            ajaxGridOptions: {
                error: function () {
                    $('#CategoriesGrdList')[0].grid.hDiv.loading = false;
                    alert('An error has occurred.');
                }
            },
            url: '@Url.Action("GetAllCategoriesList", "Categories")/' + 0,
            gridview: true,
            autoencode: true,
            postData: { categoryId: 1 },
            datatype: 'json',
            jsonReader: { root: 'List', page: 'Page', total: 'TotalPages', records: 'TotalCount', repeatitems: false, id: 'Id' },
            mtype: 'GET',
            colNames: ['Id', 'Code', 'Description', 'IsActive', "actions"],
            colModel: [
                  { name: 'Id', index: 'Id', hidden: false, key: true },
                { name: 'Code', index: 'Code', width: 170},
                { name: 'Description', index: 'Description', width: 170},
            { name: 'IsActive', index: 'IsActive', width: 170 },
            {
                name: 'actions', index: 'actions', formatter: 'actions',
                formatoptions: {
                    keys: true,
                    editbutton: true,
                    delOptions: { url: '@Url.Action("DeleteCategory", "Categories")' }
                }
            }
            ],
            pager: $('#CategoriesGrdPager'),
            sortname: 'Code',
            rowNum: 3,
            rowList: [3, 6, 9],
            width: '500',
            height: '100%',
            viewrecords: true,
            multiselect: false,
            caption: "Categories",
            loadComplete: function () {
                $("tr.jqgrow:odd").css("background", "#E0E0E0");
            },
            beforeSelectRow: function (rowid, e) {
                return false;

            },
            sortorder: 'desc'
        }).navGrid('#CategoriesGrdPager', { edit: true, add: false, del: false, search: false, refresh: true });

请指导我。

4

1 回答 1

1

要在 JQGrid 中制作您自己的编辑操作/按钮,您需要将默认的 Edit navGrid 按钮/操作设置为 false,然后将自定义按钮添加到导航网格。下面是一个示例 - 请记住删除上面 jqgrid 链接函数中的 navGrid 设置:

$('#CategoriesGrdList').jqGrid('navGrid', '#CategoriesGrdPager', { edit: false, add: false, del: false, search: false, refresh: true})
        .navButtonAdd('#CategoriesGrdPager', {
            title: "Edit",
            caption: "Edit",
            buttonicon: "ui-icon-pencil", // JQuery UI Icon
            onClickButton: function () { /*CALL YOUR FUNCTION HERE*/ },
            position: "last" // Position of the button on Nav
        })'
于 2014-09-15T15:20:43.803 回答