Skip to Content
author's profile photo Former Member
Former Member

Table View Iterator using MVC approach

I see most of the solutions in SDN is for Classical BSP page programming model and very few for MVC design pattern. Could someone please help me understand how to use iterator using MVC? This is what I did and it is giving me error - "A dynamic type conflict occurred during reference assignment."

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

Code

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

Implemented the interface IF_HTMLB_TABLEVIEW_ITERATOR in a class - ZPESTVI_REVWTYPE

Defined class attribute M_ROW_REF instance public type ref to zt_revw_type (table type)

Implemented the methods:

IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS.

FIELD-SYMBOLS: <def> LIKE LINE OF p_column_definitions.

APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.

<def>-COLUMNNAME = 'REVW_CODE'.

<def>-SORT = 'X'.

APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.

<def>-COLUMNNAME = 'REVW_DESC'.

<def>-EDIT = 'X'.

<def>-SORT = 'X'.

APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.

<def>-COLUMNNAME = 'ACTV_FLAG'.

<def>-EDIT = 'X'.

<def>-SORT = 'X'.

method: IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_ROW_START.

m_row_ref ?= p_row_data_ref.

method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.

CASE p_column_key.

WHEN 'ACTV_FLAG'.

p_replacement_bee = CL_HTMLB_CHECKBOX=>FACTORY

( id = p_cell_id

checked = 'm_row_ref->ACTV_FLAG' ).

ENDCASE.

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

In my controller:

DO_REQUEST

  • create the iterator

create object c_iterator type ZPESTVI_REVWTYPE.

  • create view instance

v_revwtype = create_view( view_name = 'zrevwtype.htm').

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

where c_iterator is defined as controller attribute instance public type ref to IF_HTMLB_TABLEVIEW_ITERATOR.

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

In my view:

<htmlb:form id="MyForm">

<htmlb:tableView id = "tv1"

visibleRowCount = "15"

selectionMode = "LINEEDIT"

table = "//vmodelsetup/m_revwtype"

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

</htmlb:form>

where v_tviterator is defined as page attribute type ref to IF_HTMLB_TABLEVIEW_ITERATOR.

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

First of all it doesn't work. Secondly, how do I display the checkbox with data binding?

Please help.

Thanks,

Partho

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2006 at 04:54 AM

    OK, Finally I got it somewhat working.

    I have taken out the code from method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_ROW_START.

    • m_row_ref ?= p_row_data_ref.

    Although m_row_ref and my table in iterator was the same table type.

    Now, the output displays checkbox with label "Flag" next to it. How do I get rid of the lable "Flag"? I tried using text=' ' but that didn't work.

    Also, I could check/uncheck any checkboxes irrespective of record selection (lineedit). Other fields are available for edit only when I select the record but all checkboxes are available for input. How do I control this?

    Finally, how can I enhance this screen to support select/insert/update/delete operation?

    Thanks a bunch.

    Partho

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 27, 2006 at 09:54 PM

    Well you can't pass 'm_row_ref->ACTV_FLAG'. The quote marks would cause you pass the text literal m_row_ref->ACTV_FLAG as the value.

    Instead to use the bind, use the attribute _checked of the factory method. the _ attributes are the ones that accept binding strings. The the method of the interator already has input parameter that will contain the binding string for the current cell value. The name of the input parameter is p_cell_binding.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 27, 2006 at 10:17 PM

    Mr Jung,

    Thanks for reponding so quickly. I do need some more guidance. Some code example would really help (MVC pattern please).

    It appears the problem is somewhere else.

    I commented everything in render_cell_start method: Right now it reads as followS:

    WHEN 'REVW_CODE'.

    IF p_edit_mode IS NOT INITIAL.

    ENDIF.

    WHEN 'REVW_DESC'.

    IF p_edit_mode IS NOT INITIAL.

    ENDIF.

    WHEN 'ACTV_FLAG'.

    IF p_edit_mode IS NOT INITIAL.

    ENDIF.

    and still getting the error.

    Problem seems to be in RENDER_ROW_START code:

    m_row_ref ?= p_row_data_ref.

    my m_row_ref has been defined as clas attribute (instance/public/type ref to - ZT_REVW_TYPE) which is a table type of structure having columns revw_code, revw_desc, actv_flag.

    In my tableview, table is bound:

    table = "//vmodelsetup/m_revwtype"

    where m_revwtype is also of type ZT_REVW_TYPE.

    Is this ok?

    If I comment the line in the method RENDER_ROW_START it works - with basic tableview display. The moment I remove the comment from RENDER_ROW_START method it fails.

    What am I doing wrong here?

    If you can give me some sample code for generating tableview with check box column it would really help. I bought the book :Advanced BSP..." but unable to find any MVC code there.

    Thanks,

    Partho

    Add a comment
    10|10000 characters needed characters exceeded

    • Are you sure that you have used the same type for your m_row_ref as the original table. Make sure one doesn't use a structure while the other has a table type.

      However if you are using data binding you might not need to cast the data reference. You can use the following code to create the checkbox with the binding string:

      WHEN 'ACTV_FLAG'.
      p_replacement_bee = CL_HTMLB_CHECKBOX=>FACTORY
      ( id = p_cell_id
        _checked = p_cell_binding ).

  • author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2006 at 04:11 AM

    Thomas,

    Thanks once again for your quick reply. However I am still stuck - it doesn't work. All I am trying to do is maintain (select, insert, update, delete) a table using iterator/tableview using MVC:

    Table Name: zrevw_type

    Tab Cols: revw_code, short_desc, long_desc, actv_flag.

    Data:

    revw_code short_desc long_desc actv_flag

    A Short A Long A X

    B Short B Long B X

    C Short C Long C

    D Short D Long D X

    I have defined a structure:

    Structure: zsrevw_type

    Col: revw_code, revw_desc, actv_flag

    TableType: zt_revw_type based on structure zsrevw_type

    Using this scenario could you please guide me with sample code how to achieve the result?

    Partho

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2006 at 01:27 PM

    Thomas,

    Thanks.

    Very helpful answers. I have marked the topic as answered. Using p_edit_mode and disabled property I was able to achieve the desired result. Also, I used text = '&nbsp;' which removed the 'Flag' text from the check box.

    I see your logic to implement select/insert/delete/update scenario. Will it be possible to direct me towards some code examples which will actually show how to track these events and update internal/db tables using MVC?

    Partho

    Add a comment
    10|10000 characters needed characters exceeded

    • >Will it be possible to direct me towards some code examples which will actually show how to track these events and update internal/db tables using MVC?

      There is really nothing MVC specific about what you want to do. Any example that works with insert/delete/update on a tableView table should work. I don't have a specific example off hand, but I'm sure if you search through the BSP weblogs you will find some examples that do that. You might also have a look at the sample application SBSEXT_TABLE. Although it may not have the exact example you are looking for, it has some very good examples for working with tables in general.

  • author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2011 at 02:02 PM

    Hi Partho Ghatak,

    I am very fresher to CRM and BSPs with MVC approach. In my company i have a requirement to make lead result view as editable so that user can change status and qualification of lead. I think you have done some what same. If you can send me coding/document, then it will be very helpful for me. Please help me.

    Thanks in Advance.

    Regards,

    Nizamuddin,

    +91-9989052354

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.