Re: How do I retreive a calculated value from a child grid
This example moves the javascript into the server-side event onSummarySectionRender.
This is where all the summary magic happens... and this event allows the return of javascript... so... might as well put it to good use.
This code will run in this server-side event...
This code will run every time the summary values change.
However... there is a little problem. The summary values get set when the grid is first rendered. We do not want this code running when the grid first gets rendered.
So... in the Client-side event onGridInitializeComplete put this...
And... in the Client-side event canGridSubmit put this...
So... when the grid first opens, our grid object namespace variable {grid.Object}.__firstRender gets set to true.
The summary code runs... but the Javascript is not executed because it only runs if {grid.Object}.__firstRender is set to false.
When any change is made to the grid, {grid.Object}.__firstRender is set to false.
If the server-side event get executed... {grid.Object}.__firstRender is now false and the javascript gets executed.
I guess it depends on why you're in the Grid... because the summary code will get executed after ANY grid update... not just on summary updates.
You could start testing for specific control changes... just depends on your needs.
This is just another way of looking at things.
This example moves the javascript into the server-side event onSummarySectionRender.
This is where all the summary magic happens... and this event allows the return of javascript... so... might as well put it to good use.
This code will run in this server-side event...
Code:
dim p as p p.summaryTotal = e.summaryValues.TOTAL.Total dim js as c js = <<%txt% if ({grid.Object}.__firstRender == false){ var pobj={grid.Object}.getParentObject(); if (pobj) { var rowNum = {Grid.Object}._selectedRow; {grid.Object}.submitGridPart(); var currentRow = pobj.getRepeatingSectionActiveRow('CONTAINER_1', true); pobj.setValue('EXTENSION:'+currentRow,p.summaryTotal); {grid.Object}.setSelectedRow(rowNum); } else { //alert('No Object Detected.'); } } %txt% js = replace_variables_in_string(js, p, "p") e.javascript = js
However... there is a little problem. The summary values get set when the grid is first rendered. We do not want this code running when the grid first gets rendered.
So... in the Client-side event onGridInitializeComplete put this...
Code:
{grid.Object}.__firstRender = true;
Code:
{grid.Object}.__firstRender = false;
The summary code runs... but the Javascript is not executed because it only runs if {grid.Object}.__firstRender is set to false.
When any change is made to the grid, {grid.Object}.__firstRender is set to false.
If the server-side event get executed... {grid.Object}.__firstRender is now false and the javascript gets executed.
I guess it depends on why you're in the Grid... because the summary code will get executed after ANY grid update... not just on summary updates.
You could start testing for specific control changes... just depends on your needs.
This is just another way of looking at things.
Comment