Author Topic: functionality for isDirty.  (Read 3236 times)

bsolTeamBglr

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 41
    • View Profile
functionality for isDirty.
« on: January 24, 2018, 03:56:22 pm »
Hi ParamQuery,

In Grid, on load i have some data (refer image onLoadPortActivity) , i have selected the row and clicked the delete button
the respective row data has been deleted (refer image onDeletePortActivity).  How do I know, the row has been delete?

Note:
In cellSave() : how to get the Grid is 'isDirty' on delete of selected row.

Thanks,
BSOl Team

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: functionality for isDirty.
« Reply #1 on: January 25, 2018, 07:35:02 am »
Your attachments are missing.

1. change event can be used to detect addition, update or deletion of records in grid. Specifically ui.deleteList.length > 0 inside the event listener whenever there is deletion of records.

https://paramquery.com/pro/api#event-change

2. isDirty ( returns true/false) can be used only when tracking in the grid is on.

https://paramquery.com/pro/api#option-trackModel

bsolTeamBglr

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: functionality for isDirty.
« Reply #2 on: January 29, 2018, 03:36:33 pm »
Hi ParamQuery,

Our requirement is not to providing the delete button over the rows. If user has selected the row and clicked on delete button (key board delete button) that particular row has been deleted. Then, how do I get to know the row has been deleted from that Grid, while clicking save button for the Grid.

Please, check with attached images.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: functionality for isDirty.
« Reply #3 on: January 29, 2018, 11:20:37 pm »
Delete key doesn't delete the rows, but clears the content of cells by setting them to undefined.

change event can be used to detect that as ui.source == 'clear' in the event listener.

Code: [Select]
change: function(evt, ui){
  if( ui.source == 'clear' ){
    //cells cleared by delete key.
  }
}


Also in a listener to save button, grid.getChanges() method can be used to check whether any field in updateList is undefined.

Code: [Select]
var changes = grid.getChanges({ format: 'byVal' }),
  updateList = changes.updateList;

updateList.forEach( function ( rd ){
  for(var key in updateList ){
    if ( rd[ key ] === undefined ){
       //cells cleared
    }
  }
})
« Last Edit: January 29, 2018, 11:35:15 pm by paramquery »

bsolTeamBglr

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: functionality for isDirty.
« Reply #4 on: February 05, 2018, 10:57:05 am »
Hi ParamQuery,

How to disable the clear data, when we click on delete button.

Ex:
 I have used : selectionModel: { type: 'row', mode: 'single',onTab: 'nextFocus'},
this is working for some grid, but not for all grids.
 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: functionality for isDirty.
« Reply #5 on: February 05, 2018, 12:36:21 pm »
Please use this:

Code: [Select]
beforeValidate: function(evt, ui){
if(ui.source=='clear'){
return false;
}    
},