Author Topic: addRow when editable = false  (Read 3739 times)

rallesaid

  • Newbie
  • *
  • Posts: 16
    • View Profile
addRow when editable = false
« on: September 13, 2016, 03:07:43 am »
Hi, i have a question,
when I add a new row whit a default value in a column 'editable:false', I add in addRow({checkEditable:false}) and the row is added whitout problem, but when i add a second row, i get this error "Uncaught primary key violation", but if i remove checkEditable:false or replace whit checkEditable:true, then i can add unlimited rows, but the default values of the column 'editable:false' is not added, how i can add multiples row whit a default value when column editable is false?
thanks :)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6210
    • View Profile
Re: addRow when editable = false
« Reply #1 on: September 13, 2016, 08:33:14 am »
primary key violation error is thrown when you try to enter duplicate values in a primary field. ( dataModel.recIndx )

Only unique values can be entered in primary key fields.

rallesaid

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: addRow when editable = false
« Reply #2 on: September 13, 2016, 05:08:05 pm »
but the new row that I add, did not add any recIndx, only added a fact to another column editable:false, obviously my column recIndx is also editable: false

rallesaid

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: addRow when editable = false
« Reply #3 on: September 13, 2016, 06:19:10 pm »
I solve whit this code:

var rowData = {indx1:'data1',index2:'data2'} //assuming indx1 and indx2 editable:false

var rowIndx = grid.addRow({
        newRow:{},                         //add void row
        rowIndx: 0,                          //at first row
        checkEditable:true
    });
var pdata = grid.pdata[0];          //get the grid data at position 0

for(i in rowData){
     pdata = rowData;           //set values of my rowData
}

grid.refreshRow({rowIndx:0})    //refresh the row