cancel
Showing results for 
Search instead for 
Did you mean: 

Column width optimzation for webdynrp table and ALV

former_member654348
Participant

Hi,

I created a custom webdynpro application, where in we have an ALV and a table. i would need to incorporate Column Width Optimization, whatever is available in normal abap ALV. i tried with 'Set_fixed_table_layout', set_resizable as ABAP_TRUE etc. but of no use.

Did any one worked on the similar requirement? your inputs would be really appreciated.

Thanks in advance.

Reagrds,

Pallavi.

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Pallavi,

By default in ALV , the column's width is optimized according to the content of its cell editor.

If you mark the table as fixed layout, column width will not be preserved. hence SET_FIXED_TABLE_LAYOUT( ABAP_FALSE ) should give you the optimized width of columns based on its contents.

Hope this helps you.

Regards,

Rama

former_member654348
Participant
0 Kudos

Tried this option as well. but no luck. 😞

ramakrishnappa
Active Contributor
0 Kudos

Hi Pallavi,

Please share the snap shot of alv table and indicate the problem in it.

It helps to analyze the exact cause of issue.

Regards,

Rama

former_member654348
Participant
0 Kudos

Hi Rama,

Please find the screenshot of the ALV below.

Thanks for your time.

Regards,

Pallavi.

former_member654348
Participant
0 Kudos

Hi Rama,

I missed something earlier, it is working now with SET_FIXED_TABLE_LAYOUT( ABAP_FALSE ) . Thanks for your help.

But 1 issue over here is, i am not able to view the scrollbar. I will need to use the browser horizontal scroll bar to right, to see the ALV scroll bar. so i tried setting scrollable column count. if i set this, the column width optimization is again missing and shwoing some extra spaces after the column text. please advice.

Again, I would need to imlement the column width optimization in a webydnpro table also. Please provide me the input on this as well.

Once again thanks a lot for your time for looking into this.

Thanks,

Pallavi.

ramakrishnappa
Active Contributor
0 Kudos

Hi Pallavi,

Its true that the width of table is now dependant on its content and hence the table width changes and hence no scroll bar seen.

Try to set the width of table by using SET_WIDTH( value = '60EX').or some other reasonable width.

Sample:


  lo_model->if_salv_wd_table_settings~set_fixed_table_layout( ABAP_FALSE  ).

  lo_model->if_salv_wd_table_settings~set_width( value = '60EX' ).

  lo_model->if_salv_wd_table_settings~set_scrollable_col_count( 10 ).

Note: Now you can see the scroll bar if table contains more than 10 columns and every time you scroll, the table width gets adjusted as per the contents of next visible 10 columns.

If you don't want to see the table width changing, we have only one way that you need to set the width of each column and set the table width as fixed layout .

Hope this helps you.

Regards,

Rama

former_member654348
Participant
0 Kudos

Thanks Rama. But if we set the table width as fixed layout, column width optimization wont work right?

Thanks,

Pallavi.

former_member654348
Participant
0 Kudos

Hi Rama,

Is it feasible like, we dont set the number of scrollable columns, but based on the space avaialble on browser it has to display those many columns which fit into display and then horizontal and veritical scrollbar.

For example, based on the column width optimization, some times it can show 10 columns on screen and some times only 8.

Thank you.

Regards,

Pallavi.


ramakrishnappa
Active Contributor
0 Kudos

Hi Pallavi,


Nagapallavi V Adhikarla wrote:

But if we set the table width as fixed layout, column width optimization wont work right?

You are right, if we set table layout as fixed, then the column optimization will be no more. Because, table width is fixed and whatever the no. of columns in it, it has to reduce/increase the width of each column to fit in its width.

When we set table layout as fixed, then we manually set the width of table columns via code.

Regards,

Rama

ramakrishnappa
Active Contributor
0 Kudos

Hi Pallavi,


Is it feasible like, we dont set the number of scrollable columns, but based on the space avaialble on browser it has to display those many columns which fit into display and then horizontal and veritical scrollbar.

For example, based on the column width optimization, some times it can show 10 columns on screen and some times only 8.

There is no standard method available to meet your requirement. But, I can suggest you some work around solution as below

  • Need to bet the width of browser
  • Compute the width of alv table by using browser width
  • Calculate the no. of columns to be available for scrolling

Sample code:


  DATA lv_alv_width TYPE string.

  DATA lv_browser_width TYPE i.

  DATA lv_cols TYPE i.

  lo_model->if_salv_wd_table_settings~set_fixed_table_layout( abap_false  ).

  lv_browser_width = (

  cl_wdr_task=>client_window->if_wdr_client_info_object~client_width / 10 ).

  lv_alv_width = lv_browser_width.

  CONDENSE lv_alv_width.

  CONCATENATE lv_alv_width 'PX' INTO lv_alv_width.

  lo_model->if_salv_wd_table_settings~set_width( value = lv_alv_width ).

  lv_cols = lv_browser_width / 10.

  lo_model->if_salv_wd_table_settings~set_scrollable_col_count( lv_cols ).

You can place this code in WDDOMODIFYVIEW( ) method, and it dynamically resets the no. of scroll columns visible on alv and width of alv table

Hope this helps you.

Regards,

Rama

former_member654348
Participant
0 Kudos

Thanks Rama. i tried implementing this, but the problem is, you are dividing the browser width by 10 to get the no. of visible columns right. we cannot hardcode it to 10 here in my case because the column width is not fixed, and the individual width of each field is not being captured(used GET_WIDTH at column level).

Thanks,

Pallavi.

ramakrishnappa
Active Contributor
0 Kudos

Hi Pallavi,

Well, the suggested workaround solution gives you approximatly better result.

I think you can modify it as you require

Let us understand how it works:

Scenario1:


     current browser width : 1066

    

     lv_broswer_width = ( 1066 / 10 ) = 107

    

Hence, setting alv width lv_alv_width = 107px

Now, to determine no. of columns for scroll.. roughly

          lv_cols = ( 107 / 10 ) = 11

Scenario2:


     current browser width : 830

    

     lv_broswer_width = ( 830 / 10 ) = 83

    

Hence, setting alv width lv_alv_width = 83px

Now, to determine no. of columns for scroll.. roughly

          lv_cols = ( 83 / 10 ) = 8

So, we are getting approximate optimized result but not exact 100%

Regards,

Rama

former_member654348
Participant
0 Kudos

Hi Rama,

The issue here is, most of the time unleass the browser is resized manually, through out the application the browser size is fixed right. but we are not sure of the size of each column (which varies dynamiaclly, as we are going for column width optimization), need to calculate the width needed for each column before displaying and check how many columns can fit into disaplay .

Thanks,

Pallavi.

Answers (2)

Answers (2)

former_member193460
Contributor
0 Kudos

Hi Pallavi,

     i am not clear with your requirement

i am assuming you are trying to achieve the following two:

1) column width adjustment -> Ino need to do anything,its active by default in alv)

2) Regarding the scrollbar, if you use activate the scrollable column, column width adjustment to the data still works provided you have more columns displayed than the scrollable column set.The scrollbar is also active.

  wd_this->lo_value->if_salv_wd_table_settings~set_scrollable_col_count( n ).

n is less than the no of columns visible.

Cheers,

Tashi

former_member184578
Active Contributor
0 Kudos

Hi,

Which Netweaver version you are on? The column width optimization/resize if available from Netweaver 7.0 Ehp1 onwards. You just have to set the set_fixed_table_layout to ABAP_TRUE.

set_fixed_table_layout( ABAP_TRUE ).

I guess you are on lower version of Netweaver, so you have to import the relevant support pack!

Check the video by thomas here:  WDA_Column_Resize5 | Flickr - Photo Sharing!

Hope this helps u,

Regards,

Kiran

http://www.flickr.com/photos/tjung/2806011790/

former_member654348
Participant
0 Kudos

Hi Kiran,

my sys is on NW7.0 only.

Component  Release       SP Level     Support package                        Desc.

GRCPINW   V1000_700   0013          SAPK-10313INGRCPINW           SAP GRC NW Plug-in

Thanks,

Pallavi.