cancel
Showing results for 
Search instead for 
Did you mean: 

Tableview onClientRowSelection - Extremely Urgent

Former Member
0 Kudos

Could somebody please help me on this one?

I have a tablevire with onRowSelection generating server event.

I want to add onClientRowSelection = <func> to the tableview, where <func> will be a javascript function asking a pop-up question "Yes/No" - selecting Yes would continue and generate the server event; No will cancel the server event.

I got the js function in place but somehow cannot call it using onClientRowSelection. Any idea?

Thanks.

Partho

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Any takers on this one please? I got the pop working on tableview rowselection but all it does is pops up the javascript alert. Selection of yes/no on the alert doesn't do anything... TV row is not selected...

Thomas, Raja, Brian and all

Please provide your guidance.

Thanks,

Partho

athavanraja
Active Contributor
0 Kudos

check this thread where i had explained how to generate row selection using javascript

Regards

Raja

Former Member
0 Kudos

I also checked the sample BSP app for this one TableViewClient.bsp - same scenario. Clicking on rowselection pops a message but the row is not highlighted or you can process user response.

If we cannot process the user response then how good is this feature?

Please advise.

Partho

Former Member
0 Kudos

ALRIGHT!!! Finally got the javascript working.

Now, when I click the tableview row, js (confirm dialog) pops up - Are you sure?(Yes/No).

Problem is - No matter what I click nothing happens after that. The row is not highlighted and server event (do_handle_request) is not triggered.

What is the final piece of this puzzle?

Thanks,

Partho

Former Member
0 Kudos

Raja, Thanks for your reply. Please help me with some code as I am really struggling with this one.

In my controller I have defined the interface

if_htmlb_tableview_iterator

Under the method section I have defined render_row_start, render_cell_start and get_column_definition for this interface.

I've created a variable on the controller c_iterator as TYPE REF TO if_htmlb_tableview_iterator.

I pass the variable in my DO_REQUEST

DATA: v_runreview TYPE REF TO if_bsp_page.

v_runreview = create_view( view_name = 'zrun2.htm').

CREATE OBJECT c_iterator TYPE zcl_run_review. "Name of controller class

v_runreview->set_attribute( name = 'v_tviterator' value = c_iterator ).

v_tviterator is defined as an attribute on the view as

v_tviterator TYPE REF TO if_htmlb_tableview_iterator

and used in the tableview

<htmlb:tableView id = "MyTV1"

keyColumn = "REVIEWNUMBER"

headerText = "<%= v_pagetitle %>"

headerVisible = "FALSE"

design = "ALTERNATING"

visibleRowCount = "3"

onRowSelection = "MyEventRowSelection"

selectionMode = "<%= v_selectionmode %>"

selectedRowIndex = "<%= v_rowselection %>"

visibleFirstRow = "<%= v_firstvisiblerow %>"

emptyTableText = "No data found"

footerVisible = "TRUE"

keepSelectedRow = "TRUE"

sort = "SERVER"

filter = "SERVER"

width = "100%"

table = "//vmodelsetup/m_reviewhead"

iterator = "<%= v_tviterator %>" />

=======================

Now, with all the code in place, can you explain me where and how to implement this new class CL_HTMLB_CLIENT_ITERATOR so that we could use the page_context attribute and use the js function. If I simply try and replace the attributes's TYPE REF TO definition to this class then it doesn't work.

Your feedback will be appreciated.

Partho

Former Member
0 Kudos

Partho,

Add page_context attribute, which you have created a instance for iterator class.

Use exporting to pass page_context attribute. See the samble code,

PAGE_CONTEXT Instance Attribute Private Type Ref To IF_BSP_PAGE_CONTEXT

create object v_iterator class_name exporting

page_context = page_context.

On your iterator class declare the page_context attribute and

declare page_context attribute on constructor method. Check CL_HTMLB_CLIENT_ITERATOR class for how constructor used and code for alert message on iterator.

Thanks!

Lakshmikandh

Former Member
0 Kudos

Thanks for the response Raja but

out = me->page_context->get_out( ).

out->print_string( html ).

page_context and print_string doesn't work. It is not a method for IF_HTMLB_TABLEVIEW_ITERATOR interface. How do I define and use this?

Thanks,

Partho

athavanraja
Active Contributor
0 Kudos

i dont have access to system right now , but check this class CL_HTMLB_CLIENT_ITERATOR.

your iterator should be same as this one.

Regards

Raja

Former Member
0 Kudos

Hi Raja,

I have defined an iterator attribute in my model already

c_iterator type ref to IF_HTMLB_TABLEVIEW_ITERATOR

I pass this in my do_request and use it in the tableview statement in the view.

<htmlb:tableView id = "MyTV1"

keyColumn = "REVIEWNUMBER"

headerText = "<%= v_pagetitle %>"

headerVisible = "FALSE"

design = "ALTERNATING"

visibleRowCount = "3"

onRowSelection = "MyEventRowSelection"

selectionMode = "<%= v_selectionmode %>"

selectedRowIndex = "<%= v_rowselection %>"

visibleFirstRow = "<%= v_firstvisiblerow %>"

emptyTableText = "No data found"

footerVisible = "TRUE"

keepSelectedRow = "TRUE"

sort = "SERVER"

filter = "SERVER"

width = "100%"

table = "//vmodelsetup/m_reviewhead"

iterator = "<%= v_tviterator %>" />

where v_tviterator on the view side is also defined as type ref to IF_HTMLB_TABLEVIEW_ITERATOR.

To your earlier response:

Where do I fit in the iterator CL_HTMLB_CLIENT_ITERATOR.

Do I need to define it on the view side only? Or replace the IF_HTMLB_TABLEVIEW_ITERATOR with the client one?

I tried all the combination but it didn't work. If I add onClientRowSelection = "TRUE" in my tableview statement then on clicking the row it shows "Error" on page.

How do I make the client row selection pop up work? It has become extremely critical for our project.

Looking forward to your advice.

Thanks,

Partho

athavanraja
Active Contributor
0 Kudos

in your iterator ( v_tviterator ) render_row_start method write the following code.

method if_htmlb_tableview_iterator~render_row_start .
  data: html type string,
        row  type string,
        out  type ref to if_bsp_writer.
  html = cl_htmlb_manager=>get_script_name_onclientrowsel( id    = p_tableview_id
                                                           index = p_row_index ).
  row = p_row_index.
  condense row.
  concatenate `<script>`
              `function `
              html
              `(){alert("` row `")}</script>`
         into html.

  out = me->page_context->get_out( ).
  out->print_string( html ).

endmethod.

this will simply ater the row number clicked, you can replace the alter function with confirm function.

Regards

Raja

Former Member
0 Kudos

Hi -

I am using MVC.

I have no code in Event handler for this since I want to trap the event on client side. I have a tableview with lineedit option. When the user clicks on a row I just want to pop up a message. If user says "Yes" then I want to continue with server event otherwise I want to fire htmlb.cancel.submit="TRUE".

In my view I have the js

<script type="text/javascript">

function userconfirm()

{

var answer = confirm ("Did you save the Food Review?")

if (answer)

return true;

else

return false;

}

</script>

My TV is:

<htmlb:tableView id = "MyTV1"

keyColumn = "REVIEWNUMBER"

headerText = "<%= v_pagetitle %>"

headerVisible = "FALSE"

design = "ALTERNATING"

onClientRowSelection = <here I need to call the js func but it only accepts Boolean value >

visibleRowCount = "3"

onRowSelection = "MyEventRowSelection"

selectionMode = "<%= v_selectionmode %>"

selectedRowIndex = "<%= v_rowselection %>"

visibleFirstRow = "<%= v_firstvisiblerow %>"

emptyTableText = "No data found"

footerVisible = "TRUE"

keepSelectedRow = "TRUE"

sort = "SERVER"

filter = "SERVER"

width = "100%"

table = "//vmodelsetup/m_reviewhead"

iterator = "<%= v_tviterator %>" />

athavanraja
Active Contributor
0 Kudos

check out the sample application for this case.

SBSPEXT_TABLE/TableViewClient.bsp

in htmlb:tableview you only set

onClientRowSelection = "true"

and in the iterator render_row_start method you have build the js for this.

check out the iterator calls associated witht he above sample application. (CL_HTMLB_CLIENT_ITERATOR)

Hope this is helpful

Regards

Raja

Former Member
0 Kudos

Can you please send the details about layout and code which u wrote in event handler....