How to get a jqGrid cell value when editing

前端 未结 23 2308
日久生厌
日久生厌 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:17

    I have a solution: 1. Using this.value to get the current editing value in the editing row. 2. Save the cell value to a hidden field when the cell lost its focus. 3. Read the hidden field when you need.

    The code:

     colModel="[
           { name: 'Net', index: 'Net', editable:true, editoptions: { dataEvents: [ { type: 'focusout', fn: function(e) {$('#HiddenNet').val(this.value);} }] }, editrules:{custom:true,}},
           { name: 'Tax', index: 'Tax', editable:true, editoptions: { dataEvents: [ { type: 'focus', fn: function(e) {this.value=$('#HiddenNet').val(); } }] }, editrules:{custom:true}}
        ]" 
    

    Good Luck

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

    its very simple write code in you grid.php and pass the value to an other page.php
    in this way you can get other column cell vaue

    but any one can make a like window.open(path to pass value....) in fancy box or clor box?

    $custom = <<<CUSTOM
    jQuery("#getselected").click(function(){
    
        var selr = jQuery('#grid').jqGrid('getGridParam','selrow'); 
        var kelr = jQuery('#grid').jqGrid('getCell', selr, 'stu_regno');
        var belr = jQuery('#grid').jqGrid('getCell', selr, 'stu_school');
        if(selr) 
    
         window.open('editcustomer.php?id='+(selr), '_Self');
    
    
        else alert("No selected row");
        return false;
    });
    
    CUSTOM;
    $grid->setJSCode($custom); 
    
    0 讨论(0)
  • 2020-11-27 18:17

    try subscribing to afterEditCell event it will receive (rowid, cellname, value, iRow, iCol) where value is your a new value of your cell

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

    you can use this directly....

    onCellSelect: function(rowid,iCol,cellcontent,e) {
                alert(cellcontent);
            }
    
    0 讨论(0)
  • 2020-11-27 18:18

    I've got a rather indirect way. Your data should have an unique id.

    First, setting a formatter

    $.extend(true, $.fn.fmatter, {          
    numdata: function(cellvalue, options, rowdata){
        return '<span class="numData" data-num="'+rowdata.num+'">'+rowdata.num+'</span>';
    }
    });
    

    Use this formatter in ColModel. To retrieve ID (e.g. selected row)

    var grid = $("#grid"), 
        rowId = grid.getGridPara('selrow'),
        num = grid.find("#"+rowId+" span.numData").attr("data-num");
    

    (or you can directly use .data() for latest jquery 1.4.4)

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

    I think an extension of this would get it for you. retrieving-original-row-data-from-jqgrid

    0 讨论(0)
提交回复
热议问题