Hi 

I am using data Grid for one of my applications. I want to save the grid data automatically after some time interval.

When i was using normal table records i was easily able to achieve that using a simple java script.

Could any one provide some pointers for that.The inbuilt Data grid actions like SendSelectedRows seems to be working only when we select the checkbox and then click save. My issue is however i want automate it after a fixed time interval.

Did you try calling the SendSelectedRows  explicitly from the javascript after your defined intervals ?

Tushar Panpaliya wrote:

Did you try calling the SendSelectedRows  explicitly from the javascript after your defined intervals ?


Thank you for the reply Tushar. Sendselectedrow is not a normal screen action so it cannot be called from JavaScript. I tried calling that button by binding the id but it's not getting called. 

Solution

The issue is solved by over riding the logic for the SendDirtyRows and giving a Post call on the click of a normal screen button.

Sample Post Call on click of the screen button.

SyntaxEditor Code Snippet

"
GridOS.dirtyItemsFeature.sendJsonDirtyElements(
    this, 
'"+ GetOwnerURLPath()+"/rest/GetBudgetPlanDetails/SaveBudgetPlanDetails',
'POST',
    false,
    '" +editabletable2.Id + "',
    '',
    '',
    true,
    true); 

this.classList.remove('wj-disabled');
this.style.cssText = '';
" 

The button has the id name : AlternativeSave


Simple script to call the button after ten seconds interval.


SyntaxEditor Code Snippet

"<script>

$(document).ready(function(){

 var timeout = setInterval(saveGrid, 10000);

function saveGrid () {

$('#" +AlternativeSave.Id  + "').click();

}});

</script>"



Solution