
I have already briefly mentioned asynchronous rendering of the tables here:
Parallelization in Web UI - Part 2
Since then I have simplified a solution to a certain extent, but I forgot to make a post about it :smile: . A new solution does not require you to use createFastRowsCallback function (which, in fact, should receive a kind of crazy input, that you have to create on your own).
Instead we will build a normal HTML-based response. It can be doe for ANY Tajax area, including the tables.
So, what is the difference?
And the changes are:
1. When building a view, we start it from our own TAJAX area (<tajax:areaid="myTajaxArea" >).
2. Moreover, we need to store its name in the controller class (controller->gr_ajax_area = page_context->element_at_top_of_stack( ).).
3. As a callback function, we are using our own one. (function UpdateMyTable(reqObj)).
<%@page language="abap" %> <script type="text/javascript"> cl_wd_utilities=>get_otr_text_by_alias( 'CRM_BSP_UI_FRAME_RECOBJ/LOADING' ). |
4. In IF_CRM_WEB_CALLBACK~HANDLE_REQUEST method we are using a new method CREATE_TABLE_VIEW_HTML_NEW, which returns an inner HTML of our TAJAX Area.
method create_table_view_html_new. " Variables data: lv_attribute_path type string, lv_model_name type string. " Strucures data: ls_area_content type crms_tajax_area_content. " References data: lo_page type ref to cl_bsp_ctrl_adapter, lo_view_manager type ref to cl_bsp_wd_view_manager, lo_view_controller type ref to cl_bsp_wd_view_controller, lo_model type ref to if_bsp_model_binding, lo_context_node_tv type ref to cl_bsp_wd_context_node_tv. " Field symbols field-symbols: <fs_page> type bsprtip. " Create page instance read table cl_bsp_context=>c_page_instances with key page_name = cl_bsp_wd_appl_controller=>appl_controller_name assigning <fs_page>. " Rendering if sy-subrc is initial and <fs_page>-instance is bound. lo_page ?= <fs_page>-instance. lo_view_manager ?= lo_page->m_adaptee. lo_view_controller ?= ir_controller. lo_view_manager->render( iv_root_view = lo_view_controller ). endif. " Get model call method cl_bsp_model=>if_bsp_model_util~split_binding_expression exporting binding_expression = iv_binding_string importing attribute_path = lv_attribute_path model_name = lv_model_name. try. lo_model ?= ir_controller->get_model( lv_model_name ). lo_context_node_tv ?= lo_model. catch: cx_root. exit. endtry. "Build table lo_context_node_tv->build_table( ). " Get AJAX Area Content By ID call method lo_view_controller->retrieve_ajax_area_content exporting iv_page_id = ir_controller->component_id iv_area_id = iv_ajax_area_id importing es_content_info = ls_area_content er_used_controller = lo_view_controller. ev_html = ls_area_content-area_content. endmethod.
|
5. We send back this inner HTML code as a part of JSON response. (Here we use a table, as probably several areas or individual fields can be processed in one request).
|
And the picture to prove that this is working.
Run simple! No crazy concatenated HTML strings!
P.S. Sorry, standard SAP's formatting is lost again. Do not know how to keep it.
BR, Dima
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
4 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |