cancel
Showing results for 
Search instead for 
Did you mean: 

Tableview Select Rows

0 Kudos

Hi,

I have a Tableview multiselect.

I need to put some of those check boxes onCreation already selected. How can I do it ?

I have a field on my interanl table that represents this, how can I connect to the checkbox on the tableview ?

Thanks,

JS

Message was edited by: Brian McKellar

-


SDN is <b>NOT</b> the place for urgent requests. If you have needed business case to fly at this attitude, then OSS is the only option. SDN is about community, about helping when one has time, about giving and taking. Urgent stuff means business is burning, and it does not belong in SDN.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member181879
Active Contributor
0 Kudos

Please read <a href="/people/brian.mckellar/blog/2004/06/11/bsp-trouble-shooting-getting-help">BSP Trouble Shooting: Getting Help</a> to get a feeling of where to look.

The attribute you are interested looks to be selectedRowIndexTable. See SBSPEXT_TABLE, page TableViewMultiSelect.bsp.

Former Member
0 Kudos

Hello Brian,

Please have a lok to my reply to Craig.

Thank you,

Timo

Former Member
0 Kudos

Check out these links for more info on tableView and iterator and check out Brian McKellar's web logs on Event handling.

For the checkboxes in the cell's that's easily done with the Iterator.

For pre-selecting rows, well you can look at this to see how we deal with the data once it's selected. I would say that if you understand what to do with it once it's selected you could probably do it in reverse to pre-select the data.

Remember the Iterater renders the cell output but the "PREVSELECTEDROWINDEXTABLE" shows which rows are selected.

Former Member
0 Kudos

Hello Craig,

Coming from the Java/Object Pascal and Perl world, I normally get along with self-education :-). Dammit, you both (you and Brian) now remember me that BSP knows really properties! When clicking on CL_HTMLB_EVENT_TABLEVIEW I only watched the methods page - of course there is nothing. It has been a long time ago where I diti Object Pascal (Delphi) that knows real properties - where in contrast Java only has settter and getter methods...

Nevertheless, getting the selected rows is done using the table view object like this:

selRows = tvFav->data->get_rows_selected(

includeCurrentSelectedRow = 'X'

).

while also available thru an event of CL_HTMLB_EVENT_TABLEVIEW and its method PREVSELECTEDROWINDEXTABLE (using a different type, INT4_Table vs. SELECTEDROWS. From my point of view it seems a bit confusing. Why not passing event specific params and a reference to the table view and its methods and props instead?

Okay, this is too philosophic perhaps. anyhow, it immediately worked - thank you both!

Btw.: I fell into anotherr trap: the documentation of htmlb:tableView does not reveal this attribute selectedRowIndexTable in the version we have it installed - however, when opening details in the tag browser, there is this attrib ;-0

Thank you,

Timo

Former Member
0 Kudos

I learned from Brian that sometimes you need to look at the most recent documentation for the most recent version of the WebAS to find the updates to things.

Try looking at the docs for Netweaver for more up-to-date info on the BSP stuff.

Former Member
0 Kudos

Rehi,

Craig, Do you know if assigning an INT4_Table to CL_HTMLB_TableView~selectedRowIndexTable works in practice? According to the class interface description, this attrib is not read-only, thus assigning such a table should have effect, or not?. However, when I do so, nothing changes. I have verified that in the debugger also with a following call to tv->data->get_rows_selected.

Using the according HTBML attribute in the frontend (BSP page) is not ideal cos always being queried. Thus, I would have to "re-implement" selection tracking for the table view.

I would prefer just to set selected rows upon onCreate once from the data read from the DB.

Greetings and thx, Timo

P.S. it seems i cannot reward your answers with point if i am not the thread owner, is that right? I would like to so so - if you have an idea how, please tell me

Former Member
0 Kudos

What code are using? Post it here - today is a bit slow with tasks so I'll be able to play around with it for you.

Point wise as far as I know you have to be thread owner. Which means you'd have to make a new thread. This is of course not really necessary. Perhaps Mark Finnern has a method who knows but again not necessary.

By following this thing through I found the code to read the selected rows.


READ TABLE selected_rows WITH key index = me->row_index
                                        key   = me->row_key
                                        TRANSPORTING NO FIELDS.
      IF sy-subrc = 0.
        delete selected_rows index sy-tabix.
      ELSE.
        selected_row-index = me->row_index.
        selected_row-key   = me->row_key.
        append selected_row to selected_rows.
      ENDIF.

So if you create the table for pre-select to match this one...just thining out loud. I'll go try it...

Message was edited by: Craig Cmehil

Former Member
0 Kudos

Hello Craig,

This preliminary code i use in onInputProcessing. Being initial for selected rows, this will be moved to onCreate event. Thus, for testing i use a flag called initial (type char1).

Dammit, I cannote get the code formatted in here (tried also HTML entities, but...) Sorry.

  • when favourites are shown, read data and state from DB...

if not ( readFavouritesFlag is initial ).

 call function 'Z_FAV_READ' tables favourites = favourites.

tvFav ?= CL_HTMLB_MANAGER=>GET_DATA(

request = request

name = 'tableView'

id = 'favourites'

).

selRows = tvFav->data->get_rows_selected(

includeCurrentSelectedRow = 'X'

).

clear favSelectedRows[].

if not ( initial is initial ).

loop at favourites assigning selectedRowIndexTable = favSelectedRows.

  • just for verifying in debugger

selRows = tvFav->data->get_rows_selected(

includeCurrentSelectedRow = 'X'

).

else.

loop at selRows assigning -index to favSelectedRows.

endLoop.

  • tvFav->data->PREVSELECTEDROWINDEXTABLE = favSelectedRows.

endIf.

endIf.

Yes, there is redundant stuff that will get removed and cleaned.

I will try your code also, seeya and thanks,

Timo

Former Member
0 Kudos

As a test I put a break point in the onCreate then I manually added records to a table

srit TYPE INT4_TABLE

Then I set the selectedRowIndexTable="<%=srit%>"

My records came up as already selected.

I'll try your code out.

Former Member
0 Kudos

BTW: try [_code] code goes here [_/code] without the _

Former Member
0 Kudos

OK, alot of playing around with your code but it seems to work ok.

Read in the table containing the index keys then plugging those into a INT4_TABLE and assigning that table to selectedRowIndexTable="<%=favourites%>"

This seems to work ok and that should allow for previous selecting rows. However most tables are a bit dynamic and therefore unless you do checking to ensure that the index in the "favourites" table matches the record at that spot in the table you won't get a match and therefore have rows selected you don't want.

former_member181879
Active Contributor
0 Kudos

<i>the documentation of htmlb:tableView does not reveal this attribute selectedRowIndexTable in the version we have</i>

Yes, sometimes code leaves home long before we get to documentation. This we fix next week.

Former Member
0 Kudos

Rehi,

Yes, using that Int4_Table for the htmlb:tableView attribute "selectedRowIndexTable" worked pretty fine for me. But the problem is that i always have to "synchronise" this table to always work, i.e. bypassing the built-in selected rows mechanism.

But using a once-assignment for onCreate is not possible using the CL_HTMLB_TableView attrib selectedRowIndexTable is not working thus, I presume? What I mean is not to use the attrib for each request on taglib level but thru a one-time assignment of currently selected rows in the controler part (ABAP / ABAP OO).

A bit confused...

However, really thank you for your effort in time and anything else!

Greetings, Timo

Former Member
0 Kudos

Hello Brian,

Great to hear. However, once you get used to use SE80 navigation, It is not that critical anymore (except for getting to know details). I often tend to use docs and not to refer the actual implementation, that is a pitfall sometimes for me

Thanks,

Timo

Former Member
0 Kudos

Have you already tried to use iterators?

Dany

Former Member
0 Kudos

Hello,

I am on this train now I did not manage to pre-set selected rows using an iterator. Until now, i have successfuly used iterators i order to manipulate TableView cells (e.g. by adding dropdown lists.).

Querying selected rows is easy within onInputProcessing like this:

selRows = tvSearch->data->get_rows_selected(

includeCurrentSelectedRow = 'X'

).

But I do not manage to pre-set rows within the RENDER_ROW_START method of the interface IF_HTMLB_TABLEVIEW_ITERATOR. The p_row_data_ref object does only offer properties such as "key" and "index", but nothing like "selected" or so.

What am I missing in order to set table rows as selected within the iterator? Thanks for any help!

Greetings, Timo

Btw.: When having a multiselect TableView, this component renders an additional column with checkboxes. However, I cannot manage to query this column (beeing a virtual one?). Object / property "p_column_key" in RENDER_CELL_START never offers this one. This would be cool in order to add icons in front / after each checkbox using e.g. CL_BSP_MIMES=>SAP_ICON( id = 'ICON_WS_PLANE' ).

Any ideas if this is possible? Or at least to add a caption for this column?

former_member181879
Active Contributor
0 Kudos

<i>Btw.: When having a multiselect TableView, this component renders an additional column with checkboxes. ... This would be cool in order to add icons in front / after each checkbox ...</i>

Nothing like this possible. This column is reserved.

Of course you could consider to not use the multiselect feature, and do this yourself. Then custom render the first column using an iterator. Render a small icon to show not selected. If the user clicks on the icon, use JavaScript to exchange the icon with another. And then you still require a hidden input field to carry the current value back to the server.

All of this is simple. If you feel like it, use SBSPEXT_HTMLB, and look at any page. Look at the <bsp:testSuite> and <bsp:testCase> tags. They render nice little icons. Click the icons. See how they cycle between not-tested, tested-ok, tested-err (without roundtrip!). Little bit of creative HTML rendering, little bit of JavaScript.

That is the nice thing about ABAP. We ship the source. You now only have to read, and then copy! Don't forget to append for us the complete solution, maybe as small weblog?

++bcm

PS: Coming to TechEd?

Former Member
0 Kudos

Hello Brian,

>

> Nothing like this possible. This column is reserved.

Doh!

>

> Of course you could consider to not use the

> multiselect feature, and do this yourself. Then

> custom render the first column using an iterator.

> Render a small icon to show not selected. If the user

> clicks on the icon, use JavaScript to exchange the

> icon with another. And then you still require a

> hidden input field to carry the current value back to

> the server.

If time permits, I will do so.

>

> All of this is simple. If you feel like it, use

> SBSPEXT_HTMLB, and look at any page. Look at the

> <bsp:testSuite> and <bsp:testCase> tags. They render

> nice little icons. Click the icons. See how they

> cycle between not-tested, tested-ok, tested-err

> (without roundtrip!). Little bit of creative HTML

> rendering, little bit of JavaScript.

Compiler does not recognise these two elements. What service pack is needed in order to obtain them?

>

> That is the nice thing about ABAP. We ship the

> source. You now only have to read, and then copy!

> Don't forget to append for us the complete solution,

> maybe as small weblog?

I will think of it, if my "quality code" is worth being posted So far I will stick to default table view usage and label the buttons accordingly for what the user has checked there per row

>

> ++bcm

>

> PS: Coming to TechEd?

I do not think so, perhaps next year. Same place or does it change?

Thanks for your reply, greetings,

Timo

former_member181879
Active Contributor
0 Kudos

>> Look at the <bsp:testSuite> and <bsp:testCase> tags.

>Compiler does not recognise these two elements. What >service pack is needed in order to obtain them?

They are in a different library, which by accident is called bsp. Just add a <%@extension name="bsp" prefix="bsp"%>.

Running the test program SBSPEXT_HTMLB, as I wrote before, would have shown you how these tags work, and also shown you in what library they are placed (and if you have them in your SP). Somewhere around 28-32 we added them for our own testing purposes.

++bcm