162
Views
3
Comments
Solved
Data Grid : AutoSave
Question

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.

UserImage.jpg
Tanuj Agarwal
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>"



2021-02-02 11-55-27
Tushar Panpaliya

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

UserImage.jpg
Tanuj Agarwal

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. 

UserImage.jpg
Tanuj Agarwal
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>"



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.