cancel
Showing results for 
Search instead for 
Did you mean: 

Standard Tables

Former Member
0 Kudos

hi all...

I have a standard table...

In which i want to select 1 column....

Is there any way by which i can recognize which column has been selected...

jagruti..

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Jagruti

In Standard Table you don't have this automatic column select functionality, how ever you can set onAction of Table Column to an event handler and you can set a variable inside the event handler and in WDMODIFYVIEW you can code as follows

to make that column as selected.

the code follows:

data: lr_table type ref to cl_wd_table.

data: lr_tab_column type ref to cl_wd_table_column.

if <the column> selected.

lr_table ?= view->get_element( ID = 'TAB' ).

lr_tab_column = lr_table->get_column( ID = 'TAB_NACHN' ).

lr_tab_column->set_cell_design( value = '06' ).

endif.

by default cell design will be '01' for columns.

you can have different values for this cell desing which you can find in WDUI_TABLE_CELL_DESIGN data element.

Regards

Abhimanyu L

Former Member
0 Kudos

hi Abhi

so for all columns there willl b diffrenet event handlers in which ill set the ID..

then in wd_modify ill rite th code ..

is it???

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Jagruti

You can use the same event handler for all the columns inside the event handler

take the ID and set it in context.

in WDDOMODIFYVIEW

replace TAB_NACHN with ID in the code which i have sent you.

Regards

Abhimanyu L

Former Member
0 Kudos

Abhi

Its not accepting the same name ....

and how do i get the id...

Former Member
0 Kudos

not getting the concept of the ID..where r u setting it..

Do i hv to craete an extra node and attribute for that...

Former Member
0 Kudos

the id of the selectd column is the ID you find in the view designer in the properties tab in the field ID (the name you gave to it).

This id will be transmitted to the action handler of onAction. You can read this ID as described above.

You could set this ID as attribute in the view controller in the action handler.

In onModify you could then read this ID e.g. wd_this->selected_column and use this ID with the code provided by ABHI.

Cheers,

Sascha

Message was edited by:

Sascha Dingeldey

Former Member
0 Kudos

so i need to create a node in the context for this purpose ...

is it??

See i got the id...

In the vent handler method im getting the id ...

Wht next..Shud i create a node now..

Former Member
0 Kudos

its up to you .. i think it is easier to define an attribute in the view controller (attributes tab of the view) for example selected_column type string.

in th action handler set this id

wd_this->selected_column = id.

Then in wddomodifyview use wd_this->selected_column to change the look of the column like abhi told you. But this only changes the look.

But you also can use a context node to store the id of the selected column.

Cheers,

Sascha

Former Member
0 Kudos

Let me tell u wht im doing..

I gave an event hadler Display for all columns..

lv_col_id is an attribute in the view

1) ONACTIONDISPLAY

wd_this->lv_col_id = wdevent->get_string( 'ID' ).

2)WDMODIFYVIEW

data: lr_table type ref to cl_wd_table.

data: lr_tab_column type ref to cl_wd_table_column.

lr_table ?= view->get_element( ID = wd_this->lv_col_id ).

lr_tab_column = lr_table->get_column( ID = wd_this->lv_col_id ).

lr_tab_column->set_cell_design( value = '06' ).

Im getting a dump...

access via null pointer ...

wht am i missing..

Former Member
0 Kudos

abhi

Can u plz explain the procedure after getting the ID once agian..

Former Member
0 Kudos

Hi Jagruti.

You use the column id for getting the table:

lr_table ?= view->get_element( ID = wd_this->lv_col_id ).

I guess the ID of the table is something different. This way lr_table will be NULL. Pls check the ID of the table in view designer and set it hard coded.

For example:

lr_table ?= view->get_element( ID = 'THE_TABLE' ).

Former Member
0 Kudos

sascha

it works fine..thanx

But i want the data of that column also..

and when i click on next column the previous selection shud not b der..

Former Member
0 Kudos

hey Abhi..

thanx.....it works...

jagruti

Former Member
0 Kudos

but can u tell me how do i get the column header and the data ..

Former Member
0 Kudos

Hi.

You could get the data by reading all elements of the table and depending on the

column ID read the corresponding bound property in a case in the action.

node->get_elemets( ).

loop all elements.

case column_id

when x

element->get_attribute( x ).

when y.

element->get_attribute( y ).

...

enndcase.

to deselect the previous selection in wddomodify you would need a new attribute for the previous col id.

ind the action first of all you would set

wd_this-old_col_id = wd_this->col_id

then wd_this->col_id = wdevent->get ...

then in wddomodify:

lr_table ?= view->get_element( ID = 'TABLE' ).

if wd_this->old_id is not initial.

lr_tab_column = lr_table->get_column( ID = wd_this->old_id ).

lr_tab_column->set_cell_design( value = '01' ).

endif.

lr_tab_column = lr_table->get_column( ID = wd_this->col_id).

lr_tab_column->set_cell_design( value = '06' ).

Cheers,

Sascha

Former Member
0 Kudos

sascha..

whts x ,y

Former Member
0 Kudos

Hi Jagruti.

come on ...

if you have a node

node

- attribute2

- attribute2

and you bind this node to your table you have for example

one column called col1 bound to attribute1

and the second column called col2 bound to attribute2

then

case col_id
  when col1
   element->get_attribute(
    EXPORTING
      name =  'ATTRIBUTE1'
    IMPORTING
      value = item_attribute1 ).
  when col2
      element->get_attribute(
    EXPORTING
      name =  'ATTRIBUTE2'
    IMPORTING
      value = item_attribute2 ).
 endcase.

where item_attribute1 or item_attribute2 are attributes of the corresponding trype.

Cheers,

Sascha

Former Member
0 Kudos

abhi..

that part is done...

Now i want the contents of or the header of the column..

any clue

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Jagruti

To Get Header Content of the Column

data: lr_table type ref to cl_wd_table.

data: lr_tab_column type ref to cl_wd_table_column.

data: lr_caption type ref to cl_wd_caption.

data: str type string.

lr_table ?= view->get_element( ID = 'TAB' ).

lr_tab_column = lr_table->get_column( ID = 'TAB_NACHN' ).

lr_caption = lr_tab_column->get_header( ).

str = lr_caption->get_text( ).

Now str has the content of the header of the Column TAB_NACHN

Regards

Abhimanyu L

Former Member
0 Kudos

ok..and wht about the contents of that column...

anythng clue on that

Former Member
0 Kudos

Jagruti,

why don't you just loop over all elements of the bound context node and based on the current selected col id read the corresponding attribute from each element of the node.

If you know the ID of the column you know the name of the attribute of the context element.

Cheers,

Sascha

Former Member
0 Kudos

Ya i did that..its working fine...

But im now creating dynamic columns..

Like when i click on insert column button im getting a new column..

So im not able to set the header for the cloumns..

and the same thng i want to do with the dynamic columns ie registe ran event handler for selecting the column..

can i do that..

jagruti

Former Member
0 Kudos

Hi.

the column has the method set_on_action( action_name ).

where action_name is the name of the action you set to the static columns in view designer.

Also there is a method set_header( lr_caption ) where lr_caption is of type CL_WD_CAPTION.

Cheers,

Sascha

Former Member
0 Kudos

hello sascha

DATA: str TYPE string.

DATA: lt_columns TYPE cl_wd_table_column=>tt_table_column,

ls_column TYPE REF TO cl_wd_table_column,

col LIKE LINE OF lt_columns.

lr_table ?= view->get_element( id = 'TABS' ).

lt_columns = lr_table->get_columns( ).

LOOP AT lt_columns INTO ls_column.

case ls_column->id.

when 'MLDU000001'.

lr_caption = -

-

-

-

-

-

-


get_header( ).

lr_caption->set_text( ' MLDU000001' ).

endcase.

ENDLOOP.

This is wht im doing ...TABS is the name of my dynamic table..

in lr_caption = get_header( )..

wht reference shud i use...

like ls_column-______->get_header( ) ..

jagruti..

Former Member
0 Kudos

and set_on_Action is not there in class cl_wd_table_column..

Former Member
0 Kudos

lr_caption = ls_column->get_header( ).

and sure there is a method set_on_action in this class too. It is implemented in the parent class CL_WD_ABSTR_TABLE_COLUMN. If it is really not ´there maybe you have a lower service pack!?

Cheers,

Sascha

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Jagruti.

When you select the table column (TabelColumn Ui Element) in the view designer

you can create an action for the onAction event of this column.

But seems that you have to create one handler per column so that you can find out which column was clicked.

The event is triggered when the user clicks the header of the column.

Cheers,

Sascha

Former Member
0 Kudos

Hi,

you don't need to have that many handlers, sascha, just use the wdevent id to

differ recognize the column and bind your actions into eg a case statement

grtz

Koen

Former Member
0 Kudos

hi sascha..

plz elaborate on this...

jagruti

Former Member
0 Kudos

Hi,

you can bind an action into the tablecolumn editor (inputfield and others)

this will directly send you to an event handler in which you can process the selection.

eg in an inputfield you can bind an action to toggling the enter button

grtz,

Koen

Former Member
0 Kudos

Hi.

Yes Koen is rite.

You can build one action for all columns and assign this action to all colums.

In the action you can find out which column was clicked as follows:


 data:
        lv_col_id type string.

  lv_col_id = wdevent->get_string( 'ID' ).

lv_col_id is the ID of the selected column then.

Sorry

Cheers,

Sascha

Former Member
0 Kudos

so only 1 action for all the columns...

but then can i get the data of that selected column as well...

or the header..

Former Member
0 Kudos

HJi Jagruti.

If you know the ID of the column you now which attribute of the context node

is bound to this column.

Then just get all elements of the node and read the corresponding attribute of each element to get all data of the column.

Cheers,

Sascha

Former Member
0 Kudos

hey but how do i give the same action for all the columns

Former Member
0 Kudos

Hi,

bind that action in each celleditor from the table

grtz

Koen

Former Member
0 Kudos

In the view designer you can set the same action for each table column in the event onAction.

Koen, if the cell editor is an text view you can not set any action. Or an input field as cell editor only has the event onEnter which is not triggered swhen the user clicks the cell. So I guess using the event of the column is the only way.

Cheers,

Sascha

Former Member
0 Kudos

sascha..

if i give the same name it says ...action already exists

Former Member
0 Kudos

Jagruti,

do not enter the name of the action, choose it from the drop down list in this field.

Cheers