How to get a jqGrid cell value when editing

前端 未结 23 2264
日久生厌
日久生厌 2020-11-27 17:43

How to get a jqGrid cell value when in-line editing (getcell and getRowData returns the cell content and not the actuall value of the input element).

相关标签:
23条回答
  • 2020-11-27 18:26

    Before i was getting : html tag of the textbox something like

    but Here is the solution to get the value from that particular column, working and tested

    function getValue(rowId, cellId) {
            var val = $("[rowId='"+rowId+"'][name='"+cellId+"']").val();
            return val;
           }
    
    var values = getValue(rowId, 'cellid');
    
    0 讨论(0)
  • 2020-11-27 18:29

    Hi, I met this problem too. Finally I solved this problem by jQuery. But the answer is related to the grid itself, not a common one. Hope it helps.

    My solution like this:

    var userIDContent = $("#grid").getCell(id,"userID");  // Use getCell to get the content
    //alert("userID:" +userID);  // you can see the content here.
    
    //Use jQuery to create this element and then get the required value.
    var userID = $(userIDContent).val();  // var userID = $(userIDContent).attr('attrName');
    
    0 讨论(0)
  • 2020-11-27 18:30

    In order to get the cell value when in-line editing you need to capture this event(or another similar event, check documentation):

    beforeSaveCell: function (rowid, celname, value, iRow, iCol) { }

    In the value parameter you have the 'value' of the cell that was currently edited.

    To get the the rest of the values in the row use getRowData()

    I lost a lot of time with this, hope this helps.

    0 讨论(0)
  • 2020-11-27 18:31

    Try this, it will give you particular column's value

    onSelectRow: function(id) {
        var rowData = jQuery(this).getRowData(id); 
        var temp= rowData['name'];//replace name with you column
        alert(temp);
    }
    
    0 讨论(0)
  • 2020-11-27 18:32

    After many hours grief I found this to be the simplest solution. Call this before fetching the row data:

    $('#yourgrid').jqGrid("editCell", 0, 0, false);
    

    It will save any current edit and will not throw if there are no rows in the grid.

    0 讨论(0)
  • 2020-11-27 18:36

    You can get it from the following way...!!

    var rowId =$("#list").jqGrid('getGridParam','selrow');  
    var rowData = jQuery("#list").getRowData(rowId);
    var colData = rowData['UserId'];   // perticuler Column name of jqgrid that you want to access
    
    0 讨论(0)
提交回复
热议问题