简体   繁体   English

如何在jQgrid中使用rowid和列名设置行数据

[英]How to set Row data using rowid and column name in jQgrid

I've added a custom icon using below code in jqgrid Actions column. 我在jqgrid“操作”列中使用以下代码添加了自定义图标。 When the cutom icon is clicked, a pop up is opened with Textarea, Save and Close buttons. 单击按钮后,将弹出一个弹出窗口,其中包含Textarea,Save和Close按钮。 When I click Save button I wanted to save the text entered in textarea to a hidden field column in jQgrid. 当我单击“保存”按钮时,我想将在textarea中输入的文本保存到jQgrid中的隐藏字段列中。 I tried 'setRowData' and 'setCell' properties but nothing works. 我尝试了“ setRowData”和“ setCell”属性,但没有任何效果。 Am I missing something here? 我在这里想念什么吗?

afterInsertRow: function (rowid, rowdata, rowelem) {
                $(this).triggerHandler("afterInsertRow.jqGrid", [rowid, rowdata, rowelem]);
                //...//
                //Start: Code for Notes Icon in Actions column
                var iCol = getColumnIndexByName(grid, 'actions');
                $(this).find(">tbody>tr#" + rowid + ">td:nth-child(" + (iCol + 1) + ")")
                        .each(function () {
                            $("<div>", {
                                title: "Custom",
                                mouseover: function () {
                                    $(this).addClass('ui-state-hover');
                                },
                                mouseout: function () {
                                    $(this).removeClass('ui-state-hover');
                                },
                                click: function (eve) {
                                    $("#change_dialog").dialog({
                                        buttons: {
                                            'Save': function () {
                                                var selRow = $(eve.target).closest("tr.jqgrow").attr("id");

                                                var txtNotes = $("#mytext").val();
                                                $("#gridJQ").setRowData(selRow, { 'notesHidden': txtNotes });

                                                $("#gridJQ").jqGrid('setCell', selRow, 'notesHidden', txtNotes);
                                                $("#gridJQ").jqGrid('setRowData', selRow, 'notesHidden', txtNotes);
                                                $(this).dialog("close");
                                            },
                                            'Close':function() {
                                                $(this).dialog("close");
                                            }
                                        }
                                    });

                                    return false;
                                }
                            }
                            ).css({ "margin-right": "5px", float: "left", cursor: "pointer" })
                                .addClass("ui-pg-div ui-inline-custom")
                                .append('<span class="ui-icon ui-icon-document"></span>')
                                .prependTo($(this).children("div"));
                        });

Instead of using this code to get the row 而不是使用此代码来获取行

var selRow = $(eve.target).closest("tr.jqgrow").attr("id");

Try something a more direct such as 尝试一些更直接的方法,例如

var selRow = $("#gridJQ").jqGrid('getGridParam', 'selrow');

Or even just var selRow = rowid . 甚至只是var selRow = rowid

Does that help at all? 这些帮助有用?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM