Author Topic: Issue with add buttons when returning default data  (Read 3939 times)

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Issue with add buttons when returning default data
« on: November 27, 2014, 09:27:23 am »
Running into a little issue:

I have an "Add row" button item in the toolbar with a listener like the following:

Code: [Select]
                                listener:{
                                    click:function(evt,ui){
                                        var $grid = $(this).closest('.pq-grid');
                                        addRow($grid,{
                                            id:null,
                                            name:null, 
                                            group_rate:0,
                                            disabled:false,
                                            tax_rates:[]
                                        });
                                    }
                                }

(The "addRow" function, incase you need to see it:)

Code: [Select]
    function addRow($grid,rowData){
        if(isEditing($grid)){
            return;
        }
        // append empty row in first row.
        var rowOptions = {
            rowIndxPage:0,
            rowData:rowData
        }
        if(typeof rowData == 'function'){
            rowOptions.rowData = rowData();
        }
        $grid.pqGrid('addRow',rowOptions);

        var $tr = $grid.pqGrid('getRow',{
            rowIndxPage:0
        });
        if($tr){
            $tr.find('button.edit_btn').first().click();
        }
    }

The problem is with the "group_rate" entry.  It never seems to show up in the rowData for the new row, although it does show for rows that were pulled from a JSON API.   If I rename it to "fgroup_rate", then it will show -- but I'd like to use the name the server side API is returning, "group_rate".

Is "group_*" a reserved name in pqGrid?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6320
    • View Profile
Re: Issue with add buttons when returning default data
« Reply #1 on: November 27, 2014, 09:54:29 am »
"group_*" is not a reserved name in paramquery, only the fields beginning with pq_ are reserved names.

Just ensure that you haven't mentioned group_* as uneditable field in colModel.

or try to pass checkEditable : false in addRow method.

http://paramquery.com/pro/api#method-addRow

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Issue with add buttons when returning default data
« Reply #2 on: November 27, 2014, 11:21:07 pm »
"group_*" is not a reserved name in paramquery, only the fields beginning with pq_ are reserved names.

Just ensure that you haven't mentioned group_* as uneditable field in colModel.

or try to pass checkEditable : false in addRow method.

http://paramquery.com/pro/api#method-addRow

Thanks.  checkEditable:false did the trick.