Skip to main content
16-Pearl
June 21, 2018
Solved

How to add the field definitions to infotable at runtime and map the dynamic results to Grid

  • June 21, 2018
  • 1 reply
  • 2553 views

Hi, 

 

I am having the 2 different infotable with different fields . 

Based on Condition , I want to show one infotable results to Grid.

How to add the dynamic field definitions and assign the results to Grid.

Field definition base type are String and Image type. 

Below is the code written in the service.

var params = {
infoTableName : "InfoTable",
dataShapeName : "DataShape1"
};
var outputInfotable1 = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var params = {
infoTableName : "InfoTable",
dataShapeName : "DataShape2"
};
var outputInfotable2 = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

//Creating Dynamic Infotable with no Datashape
var params = {
infoTableName: "MyInfoTable"
};
var result= Resources["InfoTableFunctions"].CreateInfoTable(params);


if(Condition)
{
var dataShapeFields = outputInfotable1.dataShape.fields;
}
else
{
var dataShapeFields = outputInfotable2.dataShape.fields;
}

for(var key in dataShapeFields) {

outputInfotable.AddField({ name: key, baseType: (""+dataShapeFields[key].baseType) });
}

for (var fieldName in dataShapeFields){

var dataobj = new Object();
......................................
.........................................
dataobj[fieldName] = image;//
result.AddRow(dataobj);
}.

 

After assigning the grid, i am getting junk data to image type field column. Getting the string type data correctly.

 

Could you please provide the example how to achieve?

 

Thank You

 

 

Best answer by PaiChung

If you use Contained mashups you can dynamically change out the actual mashup / grid to match your service

If you check show all columns on a grid you can show data without a datashape

I think in one of the newer grid versions (from the market place?) you might be able to assign the datashape on the fly, uncertain about that.

1 reply

PaiChung22-Sapphire IAnswer
22-Sapphire I
June 21, 2018

If you use Contained mashups you can dynamically change out the actual mashup / grid to match your service

If you check show all columns on a grid you can show data without a datashape

I think in one of the newer grid versions (from the market place?) you might be able to assign the datashape on the fly, uncertain about that.