Dynamic columns in datagrid
Hi,
I have a datagrid with a dataprovider.
And,I am trying to set the number of columns and column
headerText values of that Datagrid based on the values from an
array.
Any suggestions on how we can do this or does anybody has
already worked on this?
Those suggestions would of very great help to me.
Assume that your colum information is contained in the Array
columnInfo which is not your dataProvider. Assume "dg" is the ID of
your DataGrid control.
var columns:Array = new Array(); // this will hold the
DataGridColumns
for(var c:int=0; c < columnInfo.length; c++) {
var col:DataGridColumn = new DataGridColumn();
col.headerText = columnInfo[c].headerText; // or whatever
holds the header text
col.dataField = columnInfo[c].dataField; // or what holds the
name of the field in the dataProvider
columns.push(col);
dg.columns = columns; // columns now added to the
DataGrid.
Similar Messages
-
Adding Dynamic column to datagrid at the begining of datagrid
Hello friends,
There is one datagrid which is static. and i m adding one dynamic column. it is get added to the end of the static datagrid
but I want to add dynamic column at the begning of the datagrid can anybody help me on this.
Thanking you,
Regards,
gajananThanks to everybody.
finally i got the things to work using following code.
private function SwapGridColumns (DG:DataGrid, Col1:Number, Col2:Number):void
var i:Number; // Counter
var DP:ArrayCollection =ArrayCollection( DG.dataProvider); //DataProvider
var Widths:Array = new Array (); // the widths of the columns
var Columns:Array = new Array (); // the column names
var Visibility:Array = new Array (); // visibility of columns
var HRenderer:Array = new Array (); // Header Renderer of columns
var IRenderer:Array = new Array();
var datastore:Array = new Array ();
var Editable:Array = new Array();
var DFields:Array=new Array();
var Sortable:Array = new Array();
for (i = 0; i<DG.columns.length; i++)
if (i == Col1)
Columns.push(DG.columns[Col2].headerText);
Widths.push(DG.columns[Col2].width);
Visibility.push(DG.columns[Col2].visible);
HRenderer.push(DG.columns[Col2].headerRenderer);
IRenderer.push(DG.columns[Col2].itemRenderer);
Editable.push(DG.columns[Col2].editable);
Sortable.push(DG.columns[Col2].sortable);
DFields.push(DG.columns[Col2].dataField);
else if (i == Col2)
Columns.push(DG.columns[Col1].headerText);
Widths.push(DG.columns[Col1].width);
Visibility.push(DG.columns[Col1].visible);
HRenderer.push(DG.columns[Col1].headerRenderer);
IRenderer.push(DG.columns[Col1].itemRenderer);
Editable.push(DG.columns[Col1].editable);
Sortable.push(DG.columns[Col1].sortable);
DFields.push(DG.columns[Col1].dataField);
else
Columns.push(DG.columns[i].headerText);
Widths.push(DG.columns[i].width);
HRenderer.push(DG.columns[i].headerRenderer);
IRenderer.push(DG.columns[i].itemRenderer);
Editable.push(DG.columns[i].editable);
Sortable.push(DG.columns[i].sortable);
DFields.push(DG.columns[i].dataField);
// Reset the widths
var col:Array
for (i = 0; i < Columns.length; i++)
var DGC:DataGridColumn = new DataGridColumn(Columns[i]);
DGC.width = Widths[i];
DGC.visible = Visibility[i];
DGC.headerRenderer = HRenderer[i];
DGC.itemRenderer = IRenderer[i];
DGC.dataField=DFields[i];
DGC.sortable=Sortable[i];
DGC.editable=Editable[i];
datastore.push(DGC);
DG.columns=datastore;
// Load DP
DG.dataProvider = DP;
Regards,
gajanan -
DataGrid with dynamic columns & renderers
I'm developing using Flash Builder 4 & Flex SDK 4.1.
I need to manage very dynamic DataGrid components and keep their definitions, which are all part of a complex item renderer of an Offers list.
The objects structure is simplified as follows -
Data: Model --> Offers ArrayCollection --> Offer VO --> DataGrid data ArrayCollection & DataGrid columns Array
View: List --> Offer Item Renderer --> DataGrid
1. Since the DataGrid's columns property accepts only an Array (not ArrayCollection), it seems like Data Binding for defining the columns is very problematic.
I tried to bind it to the source property of an ArrayCollection that would keep my columns definitions, but it didn't really work (mainly header display bugs).
What is the recommended way to keep the dynamic columns definition of a DataGrid?
2. Each column can have a set of dynamic properties, so I created a "mutant" - Column VO that extends DataGridColumn and got a dynamic properties ArrayCollection on it.
The columns got a custom header renderer that includes an icon when there are properties.
The header renderers got 4 main states (NotSelectedWithProperties, SelectedWithProperties, NotSelectedWithoutProperties & SelectedWithoutProperties).
However, the header renderer area seems a bit buggy when maintaning dynamic columns.
Any thoughts on the subject?
3. Anyway, I ended up recreating the DataGrid's columns Array very often (copying the columns definition on the offer's item renderer's dataChange event handler).
Note that the dynamic properties can be edited when the column is selected and I copy their values from the view back to the model when entering the state NotSelectedWithProperties.
This feels way too complicated and I really try to keep it simple, inspite of the required complexity.
Does anyone have better ideas?
4. In some cases the column's item renderer should also be modified into another DataGrid (grid-in-grid).
I used the MXDataGridItemRenderer with a DataGrid and included an ArrayCollection for the "newValue" returned by the editor.
(I use RendererIsEditor=true and on updateComplete populate that variable with the DataGrid's dataProvider contents)
When needed, I loop though the data objects of the parent DataGrid and populate the related field with an ArrayCollection of key-value objects that are displayed on the internal DataGrid.
After adding this feature I encounter very strange bugs -
a. After editing the grid-in-grid values and changing the column's state (selecting & deselecting), I get the following exception:
ArgumentError. Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/setChildIndex()
at mx.core::UIComponent/setChildIndex().......6993....
All I could find about this is that it might be related to some context error or something, but I'm really stuck on this one.
b. Sometimes another column might copy value from one row to another, running over the previous value.
I'm not sure exactly what sequence of actions causes this behavior, but it's related to that itemRenderer for sure.
c. Switching places with a column that uses the grid item renderer (headerShift) causes a stak overflow of StyleManager that tried to get style from the DataGridItemRenderer. This one I just found out, but couldn't reproduce a second time... strange!
I'm pretty sure this caused another problem that I don't remember at the moment.
The bottom line is that there got to be a better way to implement this feature within this already-complicated environment.
Maybe I'm doing something very wrong here...
Please advice and thanks for reading all this.Update on item 4a -
This was a major issue (the main reason for opening this thread really) and I managed to resolve it!
As part of my application, I override the default DataGrid behavior for column selection (headerRelease event).
Instead of sorting, I change the column's header looks and define it as Selected (for showing its dynamic properties and enable its deletion).
At first I did this by setting styles, but the look didn't refresh unless I created a new instance of the header renderer.
Later I changed thi behavior to work with states, but I left the new header renderer instance creation commands and those lines created all the mess!
Conclusion -
If you define a custom header renderer for your datagrid column and then a custom item renderer, don't create a new instance of your header renderer!
It would still be nice to get some response for the other issues I raised.
Thanks and have a nice week. -
Dynamic dataprovider in Datagrid combobox.
Hi,
i am using Flex 3. I have a data grid with first two rows having item renderers as ComboBoxes. What i want to implement is that, depending on my selection in the first combobox, the respective second combobox should get a dataprovider of my choice.
For e.g.
If I select the 1st combobox as India, then the adjacent combobox should have the cities in India.
If I select the 1st combobox as France, then the adjacent combobox should have the cities in France.
I dont have the values in any local variables. The values must be fetched at runtime because the list of Countries(in first combobox) is very exaustive so fetching the list of all cities for all countries would not be right. So for each selection of country i have to make an http service call to fetch the corresponding city list.
My question is how do i dynamically give the cities as dataprovider to each of the combo boxes in each row.
Hope my description is comprehensible enough.
Thanks
Sid.HI,
Can you check the below code. If that is what you need.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
creationComplete="application1_initializeHandler(event)">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
// Defines your collections
[Bindable]
public var countriesData:ArrayCollection=new ArrayCollection([{label: 'India'}, {label: 'Brazil'}]);
[Bindable]
public var citiesData:ArrayCollection;
[Bindable]
public var collection:ArrayCollection=new ArrayCollection();
protected function application1_initializeHandler(event:FlexEvent):void
dataGrid.addEventListener("countryChanged", country_changed_handler);
collection.addItem({cityData:citiesData});
// Change this method to the remote callings.
// In the resultEvent you will change the citiesData collection.
protected function country_changed_handler(event:DataEvent):void
if (event.data == 'India')
dataGrid.selectedItem.cityData = new ArrayCollection([{label: 'Mumbai'}, {label: 'Delhi'}]);
else
dataGrid.selectedItem.cityData = new ArrayCollection([{label: 'São Paulo'}, {label: 'Rio de Janeiro'}]);
dataGrid.invalidateList();
public function addRow(event:MouseEvent):void{
//collection.addItem(new Object());
collection.addItem({cityData:citiesData});
public function dropRow(event:MouseEvent):void{
]]>
</mx:Script>
<mx:DataGrid id="dataGrid"
dataProvider="{collection}">
<mx:columns>
<mx:DataGridColumn>
<mx:itemRenderer>
<mx:Component>
<mx:ComboBox dataProvider="{this.parentDocument.countriesData}"
labelField="label"
change="combobox1_changeHandler(event)"
selectedIndex="-1">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.ListEvent;
protected function combobox1_changeHandler(event:ListEvent):void
dispatchEvent(new DataEvent("countryChanged", true, true, this.selectedLabel));
]]>
</mx:Script>
</mx:ComboBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn>
<mx:itemRenderer>
<mx:Component>
<mx:ComboBox labelField="label">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
super.data = value;
var prevSelectedItem:Object = this.selectedItem;
this.dataProvider = data.cityData ;
this.selectedItem = prevSelectedItem;
]]>
</mx:Script>
</mx:ComboBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:HBox width="299" horizontalAlign="center" horizontalGap="51">
<mx:Button label="Add" click="addRow(event)"/>
<mx:Button label="Drop" click="dropRow(event)"/>
</mx:HBox>
</mx:Application> -
Rearrange column in Datagrid in Flex
Hi, i am retrieving data from database using arraycollection to fill in the datagrid with dynamic column header, and the columns are arranger alphabatically depend on the column header title, for my case i want to rearrange the columns depend on specific order, i created another function to rearrange the columns, and its working fine for the first page load but when i change the dropdown entries i get all the columns rearranged but without data only the first column contain data which is [EngName]
the following is my code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="vertical" width="70%" backgroundAlpha="1" backgroundColor="white" xmlns:local="*">
<mx:WebService id="wsExec" wsdl="http://wfsvc-test/ExecSummaryReport.asmx?WSDL" useProxy="false" showBusyCursor="true">
<mx:operation name="GetExecSummary2" result="handleExecSummaryResult(event)" fault="handleFault(event)"/>
</mx:WebService>
<mx:WebService id="wsAdmin" wsdl="http://wfsvc-test/Admin.asmx?wsdl" useProxy="false" showBusyCursor="true">
<mx:operation name="SelectDirectorates" result="handleDir(event)" fault="handleFault(event)"/>
<mx:operation name="SelectSections" result="handleSec(event)" fault="handleFault(event)"/>
</mx:WebService>
<mx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridColumn;
import mx.messaging.AbstractConsumer;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
private var gridData:ArrayCollection;
[Bindable]
private var dirData:ArrayCollection;
[Bindable]
private var secData:ArrayCollection;
private function init():void
wsAdmin.SelectDirectorates();
var today:Date = new Date();
today.setDate(1);
dtFrom.selectedDate =today;
dtTo.selectedDate = new Date();
private function handleExecSummaryResult(event:ResultEvent):void
for each(var objTbl:Object in event.result.Tables)
gridData = objTbl.Rows as ArrayCollection;
dg.dataProvider = gridData;
var columns:Array = dg.columns.sort(orderColumns);
dg.columns = columns;
dg.visible = true;
private function orderColumns(a:DataGridColumn, b:DataGridColumn):int{
if (a.headerText == "EngName" || b.headerText == "EngName"){
return -1;
}else if (a.headerText < b.headerText){
return -1;
}else if (a.headerText > b.headerText){
return 1;
} else {
return 0;
private function handleDir(event:ResultEvent):void
var dirArr:Array = new Array();
var defaultItem:Object = new Object();
defaultItem['data'] = '00';
defaultItem['label'] = '-- Select Directorate --';
dirArr.push(defaultItem);
for each(var objTbl:Object in event.result.Tables)
for each(var objRow:Object in objTbl.Rows)
var obj:Object = new Object();
obj['label'] = objRow['EngDir'];
obj['data'] = objRow['DirCode'];
dirArr.push(obj);
dirData = new ArrayCollection(dirArr);
private function handleSec(event:ResultEvent):void
var secArr:Array = new Array();
var defaultItem:Object = new Object();
defaultItem['data'] = '00';
defaultItem['label'] = '-- Select Section --';
secArr.push(defaultItem);
for each(var objTbl:Object in event.result.Tables)
for each(var objRow:Object in objTbl.Rows)
var obj:Object = new Object();
obj['label'] = objRow['EngSec'];
obj['data'] = objRow['SecCode'];
secArr.push(obj);
secData = new ArrayCollection(secArr);
private function handleFault(event:FaultEvent):void
Alert.show(event+'');
]]>
</mx:Script>
<mx:Label width="100%" textAlign="center" text="Executive Summary Report" fontSize="24"/>
<mx:HBox width="100%">
<mx:HBox width="100%" horizontalAlign="right" verticalAlign="middle" >
</mx:HBox>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label text="Search: From"/>
<mx:DateField id="dtFrom" name="n1" formatString="DD/MM/YYYY"/>
<mx:Label text=" To "/>
<mx:DateField id="dtTo" name="n1" formatString="DD/MM/YYYY"/>
<mx:Label text=" Directorate:"/>
<mx:ComboBox id="ddlDir" dataProvider="{dirData}" width="170">
<mx:change>
<![CDATA[
wsAdmin.SelectSections(ddlDir.selectedItem['data'].toString());
]]>
</mx:change>
</mx:ComboBox>
<mx:Label text=" Section:"/>
<mx:ComboBox id="ddlSec" dataProvider="{secData}" width="170"/>
<mx:Label text="Status: "/>
<mx:CheckBox id="chkCompleted" label="Completed" selected="true">
<mx:click>
<![CDATA[
chkCompleted.selected = true;
chkInProgress.selected = false;
]]>
</mx:click>
</mx:CheckBox>
<mx:CheckBox id="chkInProgress" label="In Progress">
<mx:click>
<![CDATA[
chkCompleted.selected = false;
chkInProgress.selected = true;
]]>
</mx:click>
</mx:CheckBox>
<mx:Button label="Show Report">
<mx:click>
<![CDATA[
if(ddlDir.selectedIndex<1 || ddlSec.selectedIndex<1)
Alert.show('Please select a Directorate & Section');
}else
wsExec.GetExecSummary2(ddlDir.selectedItem['data'],ddlSec.selectedItem['data'],chkInProgr ess.selected,dtFrom.selectedDate,dtTo.selectedDate);
]]>
</mx:click>
</mx:Button>
</mx:HBox>
<mx:DataGrid id="dg" width="100%" rowCount="12" visible="false"/>
</mx:Application>I'm suspicous about how it can return -1 for both A.headerText and
b.headerText == "EngName" -
Create dynamic column from xml file
Hi All,
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="white" width="500" height="300" creationComplete="onload()" >
<mx:Style>
DataGrid {
alternatingItemColors: #a1a1a1,#8bb8e6;
borderColor:#050505; borderStyle:outset;
color:#ffffff;
editable:false;
fontSize:11; fontWeight:bold; fontFamily:Tahoma;
horizontalGridLines:false;
headerStyleName:myHeaderStyles;
headerSeparatorSkin:ClassReference("mx.skins.ProgrammaticSkin");
rollOverColor:#5CC2F7;
selectionColor:#E8C76D; sortableColumns:true;
textAlign:center; textRollOverColor:#FD0606; textSelectedColor:#1301FF;
variableRowHeight:true;
verticalAlign:middle; verticalGridLines:false; verticalGridLineColor:#050505;
wordWrap: false;
.myHeaderStyles
color: #ffffff;
fontWeight: bold; fontFamily:Arial; fontSize:13;
</mx:Style>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.charts.renderers.CircleItemRenderer;
import mx.charts.series.ColumnSeries;
[Bindable]
public var myData:ArrayCollection;
private var now:Date=new Date();
private var str:String;
private var st:String;
public function onload():void
str=String(now.getDate())+' '+String(now.getMonth())+' '+String(now.getFullYear())+' '+String(now.getHours())+' '+String(now.getMinutes()+' '+String(now.getSeconds()));
trace(str);
st=srv.url="Data/NumberChart.xml?rand="+str;
trace(st);
srv.send();
public function onresult():void
myData=ArrayCollection(srv.lastResult.Document.Record)
trace(myData);
]]>
</mx:Script>
<!-- xml path (data passing) -->
<mx:HTTPService id="srv" result="onresult()" />
<mx:WipeRight id="myWR" duration="2000"/>
<mx:WipeLeft id="myWL" duration="2000"/>
<mx:HBox label="Home Team" width="100%" height="100%" backgroundColor="white">
<mx:DataGrid id="HomeTeam" dataProvider="{myData}" creationCompleteEffect ="{myWR}" width="500" height="300" headerBackgroundSkin="@Embed(source='assets/Tileimage4movieplayer_img.png')">
<mx:columns>
<mx:DataGridColumn id="Hcol1" headerText="Player" draggable="false" dataField="DisField" width="170" showDataTips="true" wordWrap="true" />
<mx:DataGridColumn id="Hcol2" headerText="Average" draggable="false" dataField="Value" width="170" showDataTips="true" wordWrap="true" />
<mx:DataGridColumn id="Hcol3" headerText="Matchs" draggable="false" dataField="Prefix" width="170" showDataTips="true" wordWrap="true" />
</mx:columns>
</mx:DataGrid>
</mx:HBox>
</mx:Application>
and my xml code is...
<?xml version='1.0' encoding='utf-8' ?>
<Document Title='50 Runs Milestone'>
<Record>
<DisField>K Sangakkara</DisField>
<Value>200.00</Value>
<runs>50</runs>
<Prefix>KXIP Vs DC</Prefix>
</Record>
<Record>
<DisField>R Sharma</DisField>
<Value>185.19</Value>
<Prefix>KXIP Vs DC</Prefix>
<runs>50</runs>
</Record>
<Record>
<DisField>W Jaffer</DisField>
<Value>151.52</Value>
<Prefix>BRC Vs CSK</Prefix>
<runs>50</runs>
</Record>
<Record>
<DisField>G Gambhir</DisField>
<Value>135.14</Value>
<Prefix>CSK Vs DD</Prefix>
<runs>50</runs>
</Record>
<Record>
<DisField>M Boucher</DisField>
<Value>125.00</Value>
<Prefix>KKR Vs BRC</Prefix>
<runs>50</runs>
</Record>
<Record>
<DisField>A Gilchrist</DisField>
<Value>119.05</Value>
<Prefix>KXIP Vs DC</Prefix>
<runs>50</runs>
</Record>
<Record>
<DisField>S Asnodkar</DisField>
<Value>113.64</Value>
<Prefix>RR Vs BRC</Prefix>
<runs>50</runs>
</Record>
</Document>
it's working but i want to crete dynamic datagrid column how to do it any idea?I actually found this topic interesting, so I made the data and code generic and created a Flex Cookbook entry, adding the ability to remove columns as well:
<?xml version='1.0' encoding='utf-8' ?>
<Document>
<Record>
<name>Bob Smith</name>
<age>48</age>
<sales>$53,000.00</sales>
<territory>Southeast</territory>
</Record>
<Record>
<name>Susan Sharma</name>
<age>37</age>
<sales>$37,000.00</sales>
<territory>Southwest</territory>
</Record>
<Record>
<name>George Freebird</name>
<age>52</age>
<sales>$49,000.00</sales>
<territory>Midwest</territory>
</Record>
</Document>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="srv.send();" >
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
[Bindable] public var myData:ArrayCollection;
public function onresult():void{
myData=ArrayCollection(srv.lastResult.Document.Record)
private function modifyColumns(evt:MouseEvent):void{
var ac:ArrayCollection = new ArrayCollection(SalesData.columns);
var actionTaken:Boolean = false;
if(evt.currentTarget.label=="Remove Column"){
for each(var col1:DataGridColumn in ac){
if(col1.headerText == headerTxt.text){
ac.removeItemAt(ac.getItemIndex(col1));
headerTxt.text = "";
SalesData.columns = ac.toArray();
actionTaken = true;
if(actionTaken){
mx.controls.Alert.show("Column " + headerTxt.text + " was removed.");
}else{
mx.controls.Alert.show("Column " + headerTxt.text + " not found.");
}else if(evt.currentTarget.label=="Add Column"){
for each(var col:DataGridColumn in ac){
if(col.headerText == headerTxt.text){
mx.controls.Alert.show("Column " + headerTxt.text + " already exists.");
return;
var dgc:DataGridColumn = new DataGridColumn();
dgc.headerText = headerTxt.text;
dgc.dataField = datafieldTxt.text;
dgc.width = 100;
ac.addItemAt(dgc, int(columnIndexTxt.text));
SalesData.columns = ac.toArray();
headerTxt.text = "";
datafieldTxt.text = "";
columnIndexTxt.text = "";
mx.controls.Alert.show("Column " + headerTxt.text + " was added.");
]]>
</mx:Script>
<mx:HTTPService id="srv" url="data.xml" result="onresult()"/>
<mx:DataGrid id="SalesData" dataProvider="{myData}" width="500" height="300">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name" width="170"/>
<mx:DataGridColumn headerText="Sales" dataField="sales" width="170"/>
<mx:DataGridColumn headerText="Territory" dataField="territory" width="170"/>
</mx:columns>
</mx:DataGrid>
<mx:Form label="Add or Remove a Column">
<mx:FormItem label="Enter column header text:">
<mx:TextInput id="headerTxt"/>
</mx:FormItem>
<mx:FormItem label="Enter column datafield (if adding):">
<mx:TextInput id="datafieldTxt"/>
</mx:FormItem>
<mx:FormItem label="Enter zero based new column index (if adding):">
<mx:TextInput id="columnIndexTxt"/>
</mx:FormItem>
<mx:FormItem label="Click to add or remove column">
<mx:HBox>
<mx:Button label="Add Column" click="modifyColumns(event);"
disabledColor="0xf1aa99"
enabled="{headerTxt.text!=''&&datafieldTxt.text!=''&&columnIndexTxt.text! =''}"/>
<mx:Button label="Remove Column" click="modifyColumns(event);"
disabledColor="0xf1aa99" enabled="{headerTxt.text!=''}"/>
</mx:HBox>
</mx:FormItem>
</mx:Form>
</mx:Application> -
How can we get Dynamic columns and data with RTF Templates in BI Publisher
How can we get Dynamic columns and data with RTf Templates.
My requirement is :
create table xxinv_item_pei_taginfo(item_id number,
Organization_id number,
item varchar2(4000),
record_type varchar2(4000),
record_value CLOB,
State varchar2(4000));
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'USES','fever','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'HOW TO USE','one tablet daily','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'SIDE EFFECTS','XYZ','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'DRUG INTERACTION','ABC','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'OVERDOSE','Go and see doctor','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'NOTES','Take after meal','TX');
select * from xxinv_item_pei_taginfo;
Item id Org Id Item Record_type Record_value State
493991 224 1265-D30 USES fever TX
493991 224 1265-D30 HOW TO USE one tablet daily TX
493991 224 1265-D30 SIDE EFFECTS XYZ TX
493991 224 1265-D30 DRUG INTERACTION ABC TX
493991 224 1265-D30 OVERDOSE Go and see doctor TX
493991 224 1265-D30 NOTES Take after meal TX
Above is my data
I have to fetch the record_type from a lookup where I can have any of the record type, sometime USES, HOW TO USE, SIDE EFFECTS and sometimes some other set of record types
In my report I have to get these record typpes as field name dynamically whichever is available in that lookup and record values against them.
its a BI Publisher report.
please suggestif you have data in db then you can create xml with needed structure
and so you can create bip report
do you have errors or .... ? -
How to change recordset bahaviour to accept dynamic column names in the where clause
Hi
im using php-mysql and i make a recordset and i want to make the column names in the where clause to be dynamic like
"select id,name from mytable where $tablename-$myvar";
but when i do this my i break the recordset and it disappear
and when i use variables from advanced recordset it only dynamic for the value of the column not for the column name
and when i write the column name to dynamic as above by hand it truns a red exclamation mark on the server behaviour panel
so i think the only way is to change the recordset behaviour is it? if so How to make it accept dynamic column names?
thanks in advance.As bregent has already explained to you, customizing the recordset code will result in Dreamweaver no longer recognizing the server behavior. This isn't a problem, but it does mean that you need to lay out your dynamic text with the Bindings panel before making any changes. Once you have changed the recordset code, the Bindings panel will no longer recognize the recordset fields.
Using a variable to choose a column name is quite simple, but you need to take some security measures to ensure that the value passed through the query string isn't attempting SQL injection. An effective way of doing this is to create an array of acceptable column names, and check that the value matches.
// create array of acceptable values
$valid = array('column_name1', 'column_name2', 'column_name3');
// if the query string contains an acceptable column name, use it
if (isset($_GET['colname']) && in_array($_GET['colname'], $valid)) {
$col = $GET['colname'];
} else {
// set a default value if the submitted one was invalid
$col = 'column_name1'
You can then use $col directly in the SQL query. -
Im getting an error when running a procedure that includes this code.
I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
DECLARE @retval AS DECIMAL(12,2)
DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
DECLARE @sqlcmd AS NVARCHAR(150)
DECLARE @paramdef NVARCHAR(150)
SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
--default
SET @retval = 0.0;
EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
SELECT @retval
DECLARE @return_value DECIMAL(12,2)
EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
@SpreadKey = 1,
@MonthNumber = 4
SELECT 'Return Value' = @return_value
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
the shoe size, the phone number or something else at run time of this entity.
In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point.
Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity.
Do you know that SQL is a declarative language? This family of languages does not use local variables!
Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.
Think about how silly this is:
SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental.
We need to see the DDL so we can re-write this mess. Want to fix it or not?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How to get the dynamic columns in UWL portal
Hi All,
I am working on UWL Portal. I am new to UWL. I have down loaded uwl.standard XML file and costomized for getting the values for "select a Subview" dropdown and I am able to see the values in the dropdown. Now my requirement is to get the dynamic columns based on the selection from dropdown value.
can any body suggest on how to get the dynamic columns in UWL portal.Hi Manorama,
1) If you have already created a portal system as mentioned in following blog
/people/marcel.salein/blog/2007/03/14/how-to-create-a-portal-system-for-using-it-in-visual-composer
2) If not, then try to create the same. Do not forgot to give the Alias name .
3) After creating a system, log on to the VC, Create one iView.
4) Now Click on "Find Data" button from the list which you can view in right side to Visual composer screen.
5) After clicking on "Find Data" button, it will ask for System. If you have created your system correctly and Alias name is given properly, then your mentioned Alias name is appeared in that list.
6) Select your system Alias name and perform search.
7) It will display all the BAPIs and RFCs in your systems.
8) Select required BAPI and develop the VC application.
Please let me know if you any further problems.
Thanks,
Prashant
Do reward points for useful answers. -
Hello All,
I have a requirement to generate dynamic column in the PDF.
I have got the same running using the below code
HEADER : <?split-column-header:XXX_TIME?><?split-column-width:@width?><?XXX_TIME_FROM?>
DATA : <?split-column-data:XXX_START?><?EMP_NO?>
The issue I am having is if i generate the output in pdf with small amount of data,it will work but I am not sure how much data can come at run time.
It can be sometime more than 50 or more columns also.In that case it truncates the data.
How can i do the same.
Pls help.
Thanks
SkIncrease the page size and printable page size, and reduce the column lengths,
so that you can accomadate them in single row.
BIP will run in single row, but we have option of making it to next row too.
But even if you make it in single row, page size has to support the length of the single row you are making :)..
so you got to increase the page width to Max -
Special characters in SBWP dynamic columns are not showing for some users
Hi experts,
We have set up a dynamic columns for business workplace. One of the field displays the comments entered by the user. Some users are able to see the values entered perfectly. But for some users, if we enter special characters like @gopal, it is not displaying the value in dynamic column.
Are there any workflow/user settings need to be changed.
Thanks
GopalI had the same issue, you should check the link between AD and CRM, so you could make a new user in AD and connect your CRM account with it, then you should return the old AD account back. It worked for me, try it :)
-
How to validate a whole column of DataGrid
I want to validate a whole column of DataGrid using
Validator.
How to do that?Thanks. It works! Prima!
It's a little bit difficult for me to write and understand the English terms correctly, cause I am German.
I did not recognize, that I had to go to the Library Module!
Here I repeat Rikk's way in German:
Im Bibliothek-Modul
Rasteransicht
Bilder selektieren
Im Menufeld Ad-hoc Entwicklung:
Freistellungsfaktor einstellen: 16:9 -
Importing From Flat File with Dynamic Columns
HI
I am using ssis 2008,i have folder in which I have Four(4) “.txt” files each file will have 2 columns(ID, NAME). I loaded 4
files in one destination, but today I receive one more “.txt” file here we have 3 columns (ID, NAME, JOB) how can I get a message new column will receive in source. And how can I create in extra column in my destination table dynamically …please help meHi Sasidhar,
You need a Script Task to read the names and number of columns in the first row of the flat file each time and store it in a variable, then create a staging table dynamically based on this variable and modify the destination table definition if one ore more
new columns need to be added, and then use the staging table to load the destination table. I am afraid there is no available working script for your scenario, and you need some .NET coding experience to achieve your goal. Here is an example you can refer
to:
http://www.citagus.com/citagus/blog/importing-from-flat-file-with-dynamic-columns/
Regards,
Mike Yin
TechNet Community Support -
halo fellow SAPiens,
i need to show dynamic columns for a particular material........the scenario is as follows....
1) there r 7 fixed columns describing the material...
2)when the material returns back to the plant for some reason , i need to insert a column which shows the date and reason(char) of return.
3)again after dispatching the material for some reason it comes back again a new column shld be displayed showin the date and reason(char).
4)if the material doesnt come back...the report shows only 7 columns.
any solution?try <a href="http://www.alvrobot.com.ar/home.php">here</a> ......its a useful tool for dealing with ALV
<b>reward points if useful</b>
Maybe you are looking for
-
How do you install itunes on a secondary hard drive
I need to move my iTunes library to a bigger hard drive. Is there a way to move it to another drive and still be able to play from it? It seems when I try to do this it just goes back to my cdrive.
-
I have an iPhone 5 and updated it to iOS7 last night but now I can't use iMessage or FaceTime as it says "waiting for activation" As well as that, it won't let me use my phone number to do iMessage or FaceTime it will only let me use my apple ID whic
-
Is there a Government Benifits Solution Accelerator?
Hi, Found this government benefits app at this url, https://demo.adobe.com/Demos/Benefits%20Enrollment%20Vision/content/Citizen/index.html Q - Is this an available solution Accelerator, or has it been depricated? Thanks in advance, Michael
-
We have deployed server OS X Server 4.0.3 and all client computer configured with DNS, Open Directory and Mail Server of OS X Server 4.0.3. It is quick to deliver mail before upgrade. And it is quick to deliver mail from iOS now. But it too slow to u
-
Select a range of files to delete
How can I select a range of files to delete? I have ten files I want to delete. Do I have to select each one individually?