0

I have implemented jqgrid with some columns out of which one is hidden. I want that column should be available in add and edit mode in inline form.In my code I have created custom add and edit buttons. So all this happen on click of these custom add and edit button. My code is as below. I want to show Renewd Cheque number only in add/edit mode.

function createTransactionGrid()
{


transactionGrid = jq("#transactionList").jqGrid(
{
    url         : urlTransactionList,
    datatype    : 'json',
    mtype       : 'POST',
    postData    : tranPostData,
    colNames    : ['voucher Id', 'transaction Num', 'Cheque Number','Renewed Cheque   Number'],
    colModel    : [
        {
            name        : 'chequeVoucherId',
            index       : 'chequeVoucherId',
            sortable    : false,
            hidden      : true

        },
        {
            name        : 'transactionNum',
            index       : 'transactionNum',
            sortable    : false,
            key         : true,
            hidden      : true
        },          
        {
            name        : 'chequeNumber',
            index       : 'chequeNumber',
            align       : 'right',
            sortable    : false,
            width       : 120,
            editable    : true                              
        },
        {
            name        : 'renewChequeNumber',
            index       : 'renewChequeNumber',
            align       : 'right',
            hidden      : true,
            sortable    : false,
            width       : 120,
            editable    : true,
            editrules   : {edithidden:true} 
        }
    ],
    pager           : '#pager_t',
    sortorder       : 'desc',
    viewrecords     : true,
    gridview        : true,
    rowList         : [5, 15, 25, 50],
    rownumbers      : true,
    forceFit        : false,
    caption         : 'Transactions Details',
    width           : 1060,
    height          : 'auto',
    loadComplete    : function(data){
        lastSel = null;
        grid_add();
    }               
}).jqGrid('navGrid', '#pager_t',
{
    edit        : false,
    view        : false,
    add         : false,
    del         : false,
    search      : false,
    refresh     : true,
    cloneToTop  : true
});

return transactionGrid;
}

function grid_add(){

    var totalRecords = transactionGrid.jqGrid('getGridParam', 'records');

    jq("#pager_t_add").removeClass('ui-state-disabled');
    transactionGrid.navButtonAdd('#'+transactionGrid[0].id+'_toppager_left',
    {
        id              : "pager_t_add",
        caption         : "Add",
        buttonicon      : "ui-icon-plus",
        title           : "Add Transactions",
        onClickButton   : function()
        {

            jq.ajax(
            {
              url       : urlAddTransaction,
              type      : 'Post',
              dataType  : 'json',
              data      : tranPostData,
              success   : createTransactionRow
            }); 
        },
        position:"last"
    });

}

function createTransactionRow(transaction)
{

    lastSel = transaction.nextTransactionNo;
    var datarow =
    {
        chequeVoucherId     : transaction.voucherId,
        transactionNum      : transaction.nextTransactionNo         
    };
    var su = transactionGrid.addRowData(transaction.nextTransactionNo, datarow,    "last");
    if(su != null)
    {
        jq("#pager_t_transaction").attr("title","Save");
        jq("#transaction_caption").html("Save");
        transactionGrid.editRow(transaction.nextTransactionNo, false);

        transactionActionFlag = 'A';

    }
 }
 return false;

}
Man
  • 67
  • 1
  • 11
  • I'm not sure that I understand you correctly. If you have a column in the grid then the column can be either hidden or visible. You can't make the column visible in specific row of the table. The **whole** column of the grid can be either hidden or visible. Probably you should better use **form editing**? See [the answer](http://stackoverflow.com/a/3405961/315935) which shows how to make visible the value from hidden column in the edit/add form. – Oleg Jul 18 '14 at 10:59
  • Actually, the column renewChequeNumber should not be visible in view mode but it should be available only for add/edit mode. This is the requirement. I seen your answer and I think it is possible only in form editing not in inline editing. Thank you. – Man Jul 18 '14 at 11:08
  • I found one solution for above query. Instead of adding hidden : true to any column I used hide and show property like jq("#hideshow").jqGrid('showCol',["renewChequeNumber"]); to show and hide any column whenever required. – Man Jul 23 '14 at 12:19

0 Answers0