FoxInCloud
dynamic grid revisited
Gravatar is a globally recognized avatar based on your email address. dynamic grid revisited
  Paul
  All
  Jun 5, 2019 @ 10:34pm

Hi,

I have now found why my dynamic grid was not working previously - it is because it contains a logical column which uses DynamicCurrentControl to switch between two different image controls.

this.DynamicCurrentControl = 'iif(table.field, "imagecontrol1", "imagecontrol2")'

FiC does not support this.
The value of table.field is changed during runtime, while the grid is visible.
I suppose I could instead add a character field to hold the correct image filename for web mode, populate it with the correct image filename when the value changes and then refresh the grid.
What would be the most efficient method of refreshing just that column in the grid?

Thanks
Paul

Gravatar is a globally recognized avatar based on your email address. re: dynamic grid revisited
  FoxInCloud Support - Thierry N.
  Paul
  Jun 6, 2019 @ 05:59am

Hi Paul

FoxInCloud has supported Column.dynamicCurrentControl since V 2.10 (09/2014).

In http://foxincloud.com/ip/ (abc@distribution.com:abc), the 'PDF' column contains 2 images (imgOK and imgKO) and has this code:

.grcPDF.DynamicCurrentControl = "iif(Nvl(lPDF, .T.), 'imgOK', 'imgKO')"

Whenever the data contained in the grid change, Image control is set dynamically for each grid row; you can see the JavaScript response in such case:

var ctp = AW.Templates.Image.subclass(); /*ImageText*/ ctp.create = function(){ var img = new AW.HTML.IMG; img.setAttribute('src', function(){ return this.getControlProperty('text') || 'Images/pdf.png';  }); var obj = this.prototype; obj.setContent('box/image', img); }; oGrid.setCellTemplate(new ctp,14,0);
oGrid.setCellCurrentControl('imgok', 14, 0);
var ctp = AW.Templates.Image.subclass(); /*ImageText*/ ctp.create = function(){ var img = new AW.HTML.IMG; img.setAttribute('src', function(){ return this.getControlProperty('text') || 'Images/pdf.png';  }); var obj = this.prototype; obj.setContent('box/image', img); }; oGrid.setCellTemplate(new ctp,14,1);
oGrid.setCellCurrentControl('imgok', 14, 1);
var ctp = AW.Templates.Image.subclass(); /*ImageText*/ ctp.create = function(){ var img = new AW.HTML.IMG; img.setAttribute('src', function(){ return this.getControlProperty('text') || 'Images/pdf.png';  }); var obj = this.prototype; obj.setContent('box/image', img); }; oGrid.setCellTemplate(new ctp,14,2);
oGrid.setCellCurrentControl('imgok', 14, 2);
var ctp = AW.Templates.Image.subclass(); /*ImageText*/ ctp.create = function(){ var img = new AW.HTML.IMG; img.setAttribute('src', function(){ return this.getControlProperty('text') || 'Images/pdf.png';  }); var obj = this.prototype; obj.setContent('box/image', img); }; oGrid.setCellTemplate(new ctp,14,3);
oGrid.setCellCurrentControl('imgok', 14, 3);
var ctp = AW.Templates.Image.subclass(); /*ImageText*/ ctp.create = function(){ var img = new AW.HTML.IMG; img.setAttribute('src', function(){ return this.getControlProperty('text') || 'Images/pdf.png';  }); var obj = this.prototype; obj.setContent('box/image', img); }; oGrid.setCellTemplate(new ctp,14,4);
oGrid.setCellCurrentControl('imgok', 14, 4);

etc.

please provide some more code and/or details to understand what happens in your case.

Gravatar is a globally recognized avatar based on your email address. re: dynamic grid revisited
  Paul
  FoxInCloud Support - Thierry N.
  Jun 6, 2019 @ 04:05pm

The error I encounter is in getHTML_grd_AW_cXML_RS_cAlias() -> VFPselectExecute(), where the SQL statement that has been constructed tries to perform a string function on a logical field :

SELECT Padr(Iif(Empty(Nvl(ShopfloorUICheckAreaStock.Selected, '')) OR '/' $ ShopfloorUICheckAreaStock.Selected,
ShopfloorUICheckAreaStock.Selected, 'Images/' + cImageWeb(Trim(Evl(ShopfloorUICheckAreaStock.Selected, 
'c:\work_foxincloud\4manufacturing-foxincloud\graphics\treeview_cppass.gif')), 
'C:\work_FoxInCloud\4manufacturing-FoxInCloud\Site\sficTest\Images\', m.this.oGDIplus)), 100) as Selected, ...

ShopfloorUICheckAreaStock.Selected is logical.

The SQL statement was constructed in getHTML_grd_AW_cXML_RS_() and this assumes an image column contains a string.

I could change the way that I use "dynamic" image columns; at this stage I am learning what is supported and what is not.

Perhaps what is going wrong is that the DynamicCurrentControl aspect is not being applied? (I haven't investigated yet)
Our dynamic grids do not set this at design time and there is also no code for FAA to adapt as many grid alterations occur at runtime only and the code is stored in the database and executed via macro substitution.

Gravatar is a globally recognized avatar based on your email address. re: dynamic grid revisited
  FoxInCloud Support - Thierry N.
  Paul
  Jun 7, 2019 @ 04:12am

I think you can just set .controlSource = '' on this column

Gravatar is a globally recognized avatar based on your email address. re: dynamic grid revisited
  Paul
  FoxInCloud Support - Thierry N.
  Jun 11, 2019 @ 09:40pm

Exactly right; not setting the controlsource makes it work without any other changes needed.
Thanks.

© 1996-2019