ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: kshipra on April 14, 2017, 02:43:29 am

Title: Adding new data to grid
Post by: kshipra on April 14, 2017, 02:43:29 am
There is one column where editable is false, but when adding new data I want that cell to be editable only on blank new row.
I cannot make column editable on Add because it makes all existing rows editable. How can I enable user to add data only in add mode.
Title: Re: Adding new data to grid
Post by: paramvir on April 14, 2017, 10:17:10 am
Implement column.editable as a callback function.

dataModel.recIndx is undefined for a new row.

Hence you can write this rule inside the callback.

Code: [Select]
column.editable = function(ui){
  var recIndx = this.option('dataModel.recIndx');
  return (ui.rowData[recIndx] == null); //would return true for a new row, while false for old row.
}
Title: Re: Adding new data to grid
Post by: kshipra on April 15, 2017, 03:25:01 am
thanks that strategy worked.

I want to add new blank rows on top of page when New Event button is clicked. So if it clicked 5 times, I want to add 5 blank rows.
I am doing Batch Save so user can add multiple items at a time

But I am getting error in pqgrid.min.js:350 Uncaught primary key violation. 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Code: [Select]
//added to increment rowIndex
var addRowCounter = 0

 {
                        type: 'button', icon: 'ui-icon-plus', label: 'New Event', listeners: [
                          {
                              "click": function (evt, ui) {
                               
                               
                                   alert(addRowcounter);
                                   $("#grid_paging").pqGrid("addRow",
                                       {
                                           rowList: [{ newRow: {}, rowIndx: addRowcounter, checkEditable: false }]
                                       });
                                   $("#grid_paging").pqGrid('addClass', { rowIndx: addRowcounter, cls: 'greenColor' });
                                 
                                  addRowcounter = addRowcounter + 1;
                              }
                          }
                        ]
                    }

Title: Re: Adding new data to grid
Post by: paramvir on April 17, 2017, 10:10:41 am
You need to ensure only unique values go into the recIndx column, otherwise the error is thrown.