Dynamic columns in ABAP queries
Hi
I want to select column names dynamically from a DDIC table. For example, the normal way is select <column_name1>, <column_name2> from <tablename>. But what I need is something like select variable1, variable2 from <tablename> where variable1 and variable2 are names of the column like variable1 = <column_name1> and variable2 = <column_name2>. Is this possible?
Santo.
Hi,
Here we go:
DATA: tabname LIKE dd03l-tabname VALUE 'T001'.
DATA: BEGIN OF field_list OCCURS 0,
field(200),
END OF field_list.
DATA: BEGIN OF query_tab OCCURS 0,
query(200),
END OF query_tab.
* building field list.
field_list-field = 'BUKRS'.
APPEND field_list.
field_list-field = 'BUTXT'.
APPEND field_list.
DATA dref TYPE REF TO data.
FIELD-SYMBOLS: <fs> TYPE ANY.
FIELD-SYMBOLS: <fs1> TYPE ANY.
* creates dynamic data
CREATE DATA dref TYPE (tabname).
ASSIGN dref->* TO <fs>.
* query table
CONCATENATE '''' '0001' '''' INTO query_tab-query.
CONCATENATE 'BUKRS >= ' query_tab-query 'AND' INTO query_tab-query SEPARATED BY space.
APPEND query_tab.
CLEAR: query_tab.
CONCATENATE '''' 'B%' '''' INTO query_tab-query.
CONCATENATE 'ORT01 LIKE ' query_tab-query '.' INTO query_tab-query SEPARATED BY space.
APPEND query_tab.
CLEAR: query_tab.
CLEAR: t001.
SELECT (field_list) INTO CORRESPONDING FIELDS OF <fs> FROM (tabname)
WHERE (query_tab).
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs> TO <fs1>.
IF sy-subrc = 0.
WRITE: <fs1>.
ELSE.
EXIT.
ENDIF.
ENDDO.
You need to be careful while building the query table. Ranges are not allowed and things like that. Please refer documentation.
Thanks and regards,
S. Chandra Mouli.
Similar Messages
-
Dynamic documents in ABAP Objects (weblog)
Hi SDNers,
Do you want to implement the following features in ABAP Screens?
1. Large font sizes and more colour options than traditional ABAP/4 (There are some limitations also)
2. ICONS and pictures in different sizes
3. Texts
4. Links
5. Pushbuttons
6. Input fields
7. Dropdown list boxes
8. Tables with row span and with column span
9. Tables with frames and without frames
10. Tables with buttons, icons, pictures, input elements and texts in it.
Then please read the below weblog to incorporate these features...
<a href="/people/venkata.ramisetti/blog/2005/12/20/dynamic-documents-in-abap-objects">Dynamic Documents in ABAP Objects</a>
Thanks,
Ramakrishnaone limitation which comes to my mind immediately is that you cannot create spool output of the dynamic document.
Regards
Raja -
Problem with dynamic columns in smartforms.
Dear SDN Experts,
I have a requirement in smartforms for dynamic columns.
i have used template with 10 columns, So from these 10 columns,Columns may vary monthly MIN 2 to MAX 10 depending on
readings with them for that month.
i cannot fix column headings also,Because headings also changes dynamically.
So Problem is if there is no data in columns,Columns is displayng empty.
For EX: In this month i have 2 columns data remaining all columns is displaying empty boxes.
Please suggest me a solution is this posible in smartforms if i use table also.
<removed by moderator>
Regrds,
MNR
Edited by: Thomas Zloch on Sep 11, 2011 3:50 PMHi friend,
See the link below it is having the solution of hiding the columns in smart forms
Hide table columns in smart form?
Create a table to display your values with 12 col and hide the columns based on the idea provided in the link above.
I think this will solve your issue if you still have queries please revert back to me i will help you.
Thanks,
Sri Hari -
I want to select specific columns from a table dynamically which are basically the columns returned by quering the user_tab_columns data dictionary which in turn has to satisfy certain condition for me.
So, what I want to do is something like:
SELECT b.(dynamic column list from a)
FROM b,
(SELECT column_name FROM user_tab_columns WHERE table_name='STH' AND ........) a
any help will be greatly appreciated.sql>create or replace procedure p_dynamic_sql
2 is
3 v_sql varchar2(4000);
4 begin
5 v_sql := 'select ';
6 for r in (select column_name
7 from user_tab_cols
8 where table_name = 'EMP'
9 and column_name like 'E%') loop
10 v_sql := v_sql || r.column_name || ',';
11 end loop;
12 v_sql := rtrim(v_sql, ',') || ' from emp';
13 dbms_output.put_line( v_sql );
14 -- do something with SQL (open cursor, etc.)
15 end;
16 /
Procedure created.
sql>exec p_dynamic_sql
select EMPNO,ENAME from emp
PL/SQL procedure successfully completed. -
Hello,
we have several possibilities to show dynamic rows (table, row repeater, multi pane), is there any possibility to achieve this for dynamic columns?
I have a table with two columns:
- TEXT
- VALUE
I want to show this table in ONE line, is there any element which can realize that? I'm working on 7.02 system
Thanks and Regards
ChristopherHi Christopher,
Can you please explain your requirement a bit more? Do you want a nested table or you want a table with dynamic columns?
You can add columns dynamically and using cell variant in the column you can also decide what UI element you want to display in the cell?
In this link, I have explained how to add Columns and Cell Variants dynamically into table:
http://wiki.sdn.sap.com/wiki/display/Community/AddCellVariantintableatruntimeinWD+ABAP
Hope this will help,
Amit -
I looked over the posts on CFChart but did not find anything
that addresses my specific problem with the cfchart. So if you can
help, I'd appreciate it very much!
What I want to do is take the dynamic name of the column
derived from the first query and use that name in the Legend. E.G.
A_R1_DIS is the first dataset, A_R1_J is the second dataset, and
A_R1_PPLI is the third dataset. Then show a line graph with each
dataset based on the first query. The X Axis displays the Date/Time
value and the Y Axis displays the number of points for each record
of time for each dataset individually. I was able yesterday to get
all three datasets to display individually but when I tried to show
the legend it either displayed only the first Dataset name
"A_R1_DIS" or it displayed "NONE". Currently the code will not
display any line on the chart and the legend repeats the A_R1_DIS
as many times as there are records in the table (60+).
I use the following query to get the dynamic column name
"SelectedDatasetColName" from the MasterDataList table.
<CFQUERY name="getSelectedDatasetColName"
datasource="#getcfdbname.EventCFDBName#">
SELECT MDL_TestName + '_' + MDL_DatasetID + '_' +
MDL_MeaningfulName as SelectedDatasetColName
FROM MasterDataList
</CFQUERY>
Here is where I'm using the "SelectedDatasetColName" value:
******************************************* queries
<CFQUERY name="DatasetHistogramQry"
datasource="#getcfdbname.EventCFDBName#">
SELECT
<cfset i = 1>
<cfloop query="getSelectedDatasetColName">
#SelectedDatasetColName# as col#i#,
<cfset i = i + 1>
</cfloop>
JDay, TheHour, TheMinute,
convert(varchar(12), JDay, 114) + ' ' + convert(varchar(12),
TheHour, 114) + ':' + convert(varchar(12), TheMinute, 114) as
DateTime
FROM vPositionHistogram
ORDER BY JDay, TheHour, TheMinute
</CFQUERY>
Here is the code for the table; which works correct:
**************************** Report Code
<TABLE>
<TR>
<TH>Day</TH>
<TH>Hour</TH>
<TH>Minute</TH>
<CFOUTPUT QUERY="getSelectedDatasetColName">
<TH>#SelectedDatasetColName# Message Count</TH>
</CFOUTPUT>
</TR>
<CFOUTPUT QUERY="DatasetHistogramQry">
<TR BGCOLOR="###IIF(DatasetHistogramQry.currentrow MOD 2,
DE('DCDCDC'), DE('FFFFFF'))#">
<TD ALIGN="center">#JDay#</TD>
<TD ALIGN="center">#TheHour#</TD>
<TD ALIGN="center">#TheMinute#</TD>
<CFSET i = 1>
<CFLOOP INDEX="X" FROM="1"
TO="#getSelectedDatasetColName.recordcount#">
<TD ALIGN="center">#evaluate("col#i#")#</TD>
<CFSET i = i + 1>
</CFLOOP>
</TR>
</CFOUTPUT>
</TABLE>
Here is the output for the table; Dynamic Column Name used to
repeat counts for each dataset.
********************************* output
Day Hour Minute A_R1_DIS Message Count A_R1_J Message Count
A_R1_PPLI Message Count
37 17 36 0 2 35
37 17 37 19 6 32
37 17 38 28 30 33
37 17 39 40 27 27
37 17 40 66 64 32
Here is the problem code. I have tried several variations on
this code but currently all it does is display a blank chart.
**************************** Chart Code
<CFCHART FORMAT="flash" CHARTHEIGHT="340" CHARTWIDTH="600"
SHOWXGRIDLINES="yes" SHOWYGRIDLINES="yes" SHOWBORDER="no"
FONTBOLD="no" FONTITALIC="no" XAXISTITLE="Timeline (Day
Hour:Minute)" YAXISTITLE="Message Counts" SHOW3D="no" ROTATED="no"
SORTXAXIS="no" SHOWLEGEND="yes" TIPSTYLE="MouseOver"
SHOWMARKERS="no">
<CFOUTPUT QUERY="DatasetHistogramQry">
<CFSET i = 1>
<CFLOOP INDEX="X" FROM="1"
TO="#getSelectedDatasetColName.recordcount#">
<CFCHARTSERIES QUERY="DatasetHistogramQry" TYPE="line"
ITEMCOLUMN="#DateTime#" VALUECOLUMN="#evaluate("col#i#")#"
SERIESLABEL="#getSelectedDatasetColName.SelectedDatasetColName#">
<CFSET i = i + 1>
</CFLOOP>
</CFOUTPUT>
</CFCHART>
Please let me know if you need any additional info on my
problem and if you can help, it is greatly appreciated!!!!
- DebraDateTime is a column in the vPositionHistogram (View). Col#i#
is the variable used to loop through the column names derived from
the getSelectedDatasetColName query. The view is populated
dynamically and the columns in it vary depending on the dataset
used to populate the view. The view can have 1 to many columns.
That is why I pull the column names from the MasterDataList table
and use a variable to get the values from each column. My column
names end up being Col1, Col2, Col3, and so on. I use that variable
in the loop to get the data from vPositionHistogram for each column
in the report/chart. I made some headway on Friday before I called
it a day, but I will try the last suggestion and post my findings
in a little while. Thanks! -
Wild card search enabling in ABAP QUERIES
Hi All
How is it possible to enable <b>wild card search</b> for the <b>selection-fields</b> of <b>ABAP Queries</b>, any help in this regard will be credited
Thanks
Sudhir.Are you asking about wild card search in SELECT statements?
The following is the help on wild card search in SELECT statements
... WHERE CITY LIKE '%town%'.
This condition is true if the column CITY contains a string containing the pattern town.
... WHERE NAME NOT LIKE '_n%'.
This condition is true if the column NAME contains a value whose second character is not n.
... WHERE FUNCNAME LIKE 'EDIT#_%' ESCAPE '#'.
This condition is true if the contents of the column FUNCNAME begin with EDIT_. -
Dynamical columns in internal table
Hi all.
I need to make an internal table with dynamical columns(i have 3 static columns and the rest depends on the number of clients that i have in a month). If it's possible, how can i do it?
Can anyone please help.
Thanks & RegardsHi,
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab. <b> *Creates a dyanamic internal table **</b>
perform get_data.
perform write_out.
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
<b>* Create dynamic internal table and assign to FS</b>
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
form get_data.
* Select Data from table.
select * into table <dyn_table>
from (p_table).
endform.
Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index
of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
Regards
Sudheer -
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 find out which abap queries were executed by a user
Dear SAP Gurus,
Is there a way to find out which abap queries were executed by an end user in the recent past??
1.I tried using the t-code "stat" BUT:
dont seem to be getting any results even though I put the start time almost 2 months back.
2.Also when using STAT, I give the report name of the query in the program field but it seems to truncate it.
Any ideas how can I find out which abap queries were executed by the end user.
thanks a lot, I'll make sure to award points for your help.STAT will give you the information for a limited period of time and is limited to the server which you are logged onto yourself. Beyond 24 hours it is of even less use even if you change the selection screen values.
If you want it for a period way back into the past, then you need to use ST03N.
There are at least 2 dependencies and 1 confusion:
1 dependency) The length of period is determined by the size (length) of the file. You can change this in ST03N (default 50MB) via the menu settings.
2 dependency) The stat collector jobs need to be scheduled to write the information to ST03N (once per hour is a legal requirement in some non-banana republic countries).
1 confusion) There is an obscure function which converts a report submit to a transaction name (there is not much difference anyway) and an even more obsure one which filters what ST03N will record and therefore whether you can read it. You can (un)filter these things away if you search the SAP Marketplace for the term "MONI".
What is of particular value from this control is that you can even detect a submission of an abap which only existed temporarily.
Also note that having this information is potentially very powerfull with respect to the users (some of them are human too), so you should expose and use it responsibly.
You should also ensure that only responsible users / auditors have access to S_TOOLS_EX. -
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 -
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.
Maybe you are looking for
-
Problem downloading ALV to Excel
Hi, I have a ALV report, in that report one of the column is Vendor (LIFNR). In ALV it is displaying with leading zero. but when i download the report into Excel, the leading zero's are truncating. Could anybody let me know the solution for this. I w
-
Selecting search box instead of navigation pane.
When I go to google then the cursor is in the search box (blinks). But when I write I find myself sitting in the navigation bar. Must first click on the search box first, then I can start typing in the right box. This is very inconvenient! IE does no
-
Streaming live video to my website
Hey all, I have Flash media server, flash media live encoder, and flash cs5. I'm gonna be using flash media live encoder to stream my desktop and webcam to my website. My current host (host gator) doesn't have rtmp enabled on their web hosting plan,
-
How to design an IDOC-XI-JDBC interface
Hello Experts! I'm looking for some guidance on how to design an interface where R/3 is sending an IDOC to XI (via IDOC Adapter Receiver), then XI transforms this data into a JDBC database INSERT action. I want to make to make the JDBC request a SYNC
-
13" MBA screen blank after waking from sleep
I got a MBA very recently and noticed that if I shut the top and soon reopen it, the screen is totally blank except for the cursor. Clicking and pressing keyboard buttons doesn't help bring me to the login screen. Eventually the screen goes black a