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

Issue with ItemListBox

Hi All,

My requirement is to create a listbox and a input field.

Suppose I enter the character 'V' in the input field, the values starting with V in the listbox has to be highlighted. Entering the next character 'I' it should highlight the values starting with 'VI' and it goes on...

I need to build this dynamic search.. Is that possible? If so, how to do it?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 16, 2009 at 10:32 AM

    Hi Lekha,

    Thank you for your response... I actually want the seach to happen as and when I enter the text and not after clicking the 'Enter' button.. OnEnter event will give the result only after Clicking on 'Enter' right?

    Add a comment
    10|10000 characters needed characters exceeded

    • Such functionality will be provided next year in NetWeaver 7.02 by the framework. It is a new option on the inputField called SuggestValues. As you type, an AJAX callback to the server fires the SearchHelp and returns the values in a dropdown list below the inputField. All of this is done by the framework and only requires that you check the SuggestValues property on the inputField.

      However before 7.02 such a construct wouldn't be possible without some search button or pressing enter in the inputField. There are no exposed events for making the call back to the server. Also before 7.02 any such event would fire the entire phase model (instead of an AJAX callback) and would be quite heavy to fire on each character that you typed.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2009 at 10:51 AM

    Hi Vidhya,

    I have created one node with Names that is bound to the ItemListBox and a Input field with an entry for Name. In OnEnter event of Input field i wrote the code.

    In WDDOINIT of view I bound the entries to the node NAMES.

    DATA lo_nd_names TYPE REF TO if_wd_context_node.
      DATA lo_el_names TYPE REF TO if_wd_context_element.
      DATA ls_names TYPE wd_this->element_names.
      DATA lt_names TYPE wd_this->elements_names.
      DATA lv_name TYPE wd_this->element_names-name.
    
    * navigate from <CONTEXT> to <NAMES> via lead selection
      lo_nd_names = wd_context->get_child_node( name = wd_this->wdctx_names ).
    
    * @TODO handle non existant child
     IF lo_nd_names IS not INITIAL.
      ls_names-name = 'Abcd'.
      append ls_names to lt_names.
      clear ls_names.
    
      ls_names-name = 'Acdc'.
      append ls_names to lt_names.
      clear ls_names.
    
        ls_names-name = 'Addc'.
      append ls_names to lt_names.
      clear ls_names.
    
      ls_names-name = 'Abbd'.
      append ls_names to lt_names.
      clear ls_names.
    
      ls_names-name = 'Abc'.
      append ls_names to lt_names.
      clear ls_names.
    
      ls_names-name = 'Rekha'.
      append ls_names to lt_names.
      clear ls_names.
       lo_nd_names->bind_table( lt_names ).
     ENDIF.

    Regards,

    Lekha.

    Edited by: Lekha on Sep 15, 2009 4:21 PM

    Edited by: Lekha on Sep 15, 2009 4:23 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2009 at 10:52 AM

    Hi,

    Continuation to above ....

    I have created one node with Names that is bound to the ItemListBox and a Input field with an entry for Name. In OnEnter event of Input field i wrote the code.

    ONENTER event -

    DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context TYPE wd_this->element_context.
      DATA lv_text TYPE wd_this->element_context-text.
    
    * get element via lead selection
      lo_el_context = wd_context->get_element( ).
    * @TODO handle not set lead selection
      IF lo_el_context IS INITIAL.
      ENDIF.
    
    * get single attribute
      lo_el_context->get_attribute(
        EXPORTING
          name =  `TEXT`
        IMPORTING
          value = lv_text ).
    
      DATA lo_nd_names TYPE REF TO if_wd_context_node.
      DATA lo_el TYPE REF TO if_wd_context_element.
      DATA lt_names TYPE wd_this->elements_names.
      DATA ls_names TYPE wd_this->element_names.
    
    * navigate from <CONTEXT> to <NAMES> via lead selection
      lo_nd_names = wd_context->get_child_node( name = wd_this->wdctx_names ).
    
    * @TODO handle non existant child
     IF lo_nd_names IS not INITIAL.
      lo_nd_names->get_static_attributes_table( IMPORTING table = lt_names ).
     ENDIF.
      DATA lv_len TYPE i.
      DATA lv_temp TYPE string.
    
      LOOP AT lt_names INTO ls_names. " WHERE name EQ lv_text.
        CALL METHOD lo_nd_names->get_element
          EXPORTING
            index        = sy-tabix
          RECEIVING
            node_element = lo_el.
        CONDENSE lv_text NO-GAPS.
        lv_len   = STRLEN( lv_text ).
        lv_temp  =  ls_names-name+0(lv_len).
        CONDENSE lv_temp.
        IF lv_temp EQ lv_text.
          IF lo_el IS NOT INITIAL.
            CALL METHOD lo_el->set_selected
              EXPORTING
                flag = 'X'.
          ENDIF.
        ELSE.
          IF lo_el IS NOT INITIAL.
            CALL METHOD lo_el->set_selected
              EXPORTING
                flag = abap_false.
          ENDIF.
        ENDIF.
    
      ENDLOOP.

    This is an example...you can try it out and can enhance it....

    Somethings like case senstiviness, if there is no entry in listbox then throw error. These you have to handle it.

    Hope this works now...

    Regards,

    Lekha.

    Edited by: Lekha on Sep 15, 2009 4:23 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 17, 2009 at 03:53 AM

    Thanks a lot Thomas and Lekha.. 😊

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 17, 2009 at 03:54 AM

    Question answered.. 😊

    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.