【问题标题】:jqgrid textbox value not getting updatejqgrid文本框值没有得到更新
【发布时间】:2014-02-20 23:55:32
【问题描述】:

问题:无法在 jqgrid 中获取文本框的可更新值。

它只是检索旧值。 示例 - jqgrid 中文本框字段的默认值为 - “0” 现在,如果我将其值更新为“1”并检查该字段,则其值不会更新为 HTML,并且无法通过以下语法使用 jqgrid 对象检索。

var rowData = $('#gerList').jqGrid('getRowData', rowId);

下面是我的 jqgrid 东西:

             $('#gerList').jqGrid({
            ajaxGridOptions: {
                error: function () {
                    $('#gerList')[0].grid.hDiv.loading = false;
                    alert('An error has occurred.');
                }
            },
            url: '@Url.Action("GetEnrolls", "Attendance")/' + 0,
            gridview: true,
            autoencode: true,
            postData: { adID: rowID },
            datatype: 'json',
            jsonReader: { root: 'List', page: 'Page', total: 'TotalPages', records: 'TotalCount', repeatitems: false, id: 'syStudentID' },
            mtype: 'GET',
            colNames: ['GrdID', 'name', 'Minutes', 'comment'],
            colModel: [
                { name: 'syID', index: 'syID', hidden: true },
                { name: 'FullName', index: 'FullName', width: 150 },
                {
                    name: 'Min', index: 'Min', width: 75, align: 'left', formatter: function (cellValue, option) {
                        return '<input type="text" style="width: 40px" name="txtMin" id="txt_' + option.rowId + '" value="' + cellValue + '" />';
                    }
                },
                { name: 'MSG', index: 'MSG', width: 150 }
            ],
            pager: $('#gerListPager'),
            sortname: 'syStudentID',
            rowNum: 40,
            rowList: [40, 80, 120],
            width: '525',
            height: '100%',
            viewrecords: true,
            beforeSelectRow: function (rowid, e) {
                console.log("final");
                var $txt = $(e.target).closest('tr').find('input[type="text"]');
                alert($txt);
                 $txt.attr('value', rowid);
                 return true; // allow row selection*/
                return true;
            },
            sortorder: 'desc'
        }).navGrid('#gerListPager', { edit: false, add: false, del: false, search: false, refresh: false });

请建议我在 jqgrid 中使用此文本框有什么问题。

在网格 UI 中,所有字段都是不可编辑的,除了文本框字段似乎总是允许编辑。

谢谢

【问题讨论】:

    标签: jqgrid jqgrid-formatter


    【解决方案1】:

    尝试使用这个:

    jQuery("#gerList").saveRow("rowid", false, 'clientArray');
    

    【讨论】:

    • 我应该在 jqgrid 中哪里写 saveRow 代码? clientArray 应该保持不变,或者我是否必须用其他值替换?谢谢。
    • 在最终创建网格后尝试使用它jQuery ("# ​​gerList") saveRow ("rowid", false, 'clientArray'); else se this link
    猜你喜欢
    • 1970-01-01
    • 2012-12-21
    • 2017-08-17
    • 1970-01-01
    • 2015-07-09
    • 1970-01-01
    • 1970-01-01
    • 2021-11-30
    • 2013-06-04
    相关资源
    最近更新 更多