在jqgrid中,如何使用对话框编辑行?

时间:2014-09-15 15:03:46

标签: jqgrid jqgrid-formatter mvcjqgrid

如何在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 });

请指导我。

1 个答案:

答案 0 :(得分:1)

要在JQGrid中创建自己的编辑操作/按钮,您需要将默认的编辑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
        })'
相关问题