cancel
Showing results for 
Search instead for 
Did you mean: 

Enable disable inputfields based on selection in DDLB in tableview iterator

former_member184111
Active Contributor
0 Kudos

Hi All,

Scenario:

There are three columns in my tabkeview First contains a DDLB with three values BETWEEN , FROM and ON .

Next two columns are inputfields of type date.

Requirement:

If the user selects FROM or ON in the DDLB , the second inputfield should be disabled and if BETWEEN is sletced both inputfields

should remain enabled.

I Tried:

on the selection event of DDLB , SET a parameter with the selected value ie BETWEEN , ON or FROM.

GET this parameter in render_cell_start and set disabled property of inputfields accordingly .

But the problem here is that Suppose i select BETWEEN in first row , both inputfields are enebled now if i select FROM

in second row the second inputfield for the First row is also disabled .

I hope there is some other proper and logical method of acchieving this.

Any hint will be of great help.

Regards,

Anubhav.

Edited by: Anubhav Jain on Oct 14, 2008 12:44 PM

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

why do you fire a server event when you select a row? it's not completely clear for me what you're planning to do. If you want to keep disabled/enabled status of the various inputfields you have to check this in the iterator too of course. I'm trying to use as few roundtrips as possible.

You have to get the tableview data changed by the user in the oninputprocessing event first otherwise the data is lost of course.

Edited by: Michael Belz on Oct 15, 2008 2:44 PM

former_member184111
Active Contributor
0 Kudos

Hi Michael,

Found the solution:

when 'ZZREQUIRED'.


        if p_edit_mode is not initial.

          data: required type ref to cl_htmlb_dropdownlistbox.

          required = cl_htmlb_dropdownlistbox=>factory( id = p_cell_id
                                                     table = m_required_ref
                                                  selection = m_row_ref->zzrequired
                                                  o n s e l e ct = 'required'                    <---server event 
                                                  nameofkeycolumn = 'NAME'
                                                  nameofvaluecolumn = 'VALUE' ).

          p_replacement_bee = required .

          reqtype = required->selection . <---read the value in DDLB for current row.


        endif.


when 'ZZENDDA'.
        data: obj_fr_zzendda type ref to cl_bsp_find_and_replace,
        obj_zzendda type ref to cl_htmlb_inputfield,
        obj_bee_zzendda  type ref to cl_bsp_bee_table.

        if p_edit_mode is not initial.

          if reqtype = 'BETWEEN' or reqtype is initial.

            clear : find , replace .

            concatenate '<i n  p u t   onCh a n ge=isit T o d a y(this.value,"' p_cell_id '");' into replace .


            find = '<i n p u t' .
            replace = replace.

            obj_fr_zzendda = cl_bsp_find_and_replace=>factory( find = find
                                                                replace = replace
                                                                mode =  `FIRST_OCCURRENCE` ).


            obj_zzendda = cl_htmlb_inputfield=>factory( id = p_cell_id type = 'date' showhelp = 'X' ).

            obj_zzendda->value = m_row_ref->zzendda.

            create object obj_bee_zzendda.
            obj_bee_zzendda->add( level = 1 element = obj_fr_zzendda ).
            obj_bee_zzendda->add( level = 2 element = obj_zzendda ).
            p_replacement_bee = obj_bee_zzendda.



          elseif reqtype = 'FROM' or reqtype = 'ON'.

            clear : find , replace .

            concatenate '<in p u t o n C h a n g e = i s i  t To d a y ( t his.value,"' p_cell_id '");' into replace .


            find = '<i n p ut' .
            replace = replace.

            obj_fr_zzendda = cl_bsp_find_and_replace=>factory( find = find
                                                                replace = replace
                                                                mode =  `FIRST_OCCURRENCE` ).


            obj_zzendda = cl_htmlb_inputfield=>factory( id = p_cell_id type = 'date' showhelp = ' ' disabled = 'true' ).

            obj_zzendda->value = m_row_ref->zzendda.

            create object obj_bee_zzendda.
            obj_bee_zzendda->add( level = 1 element = obj_fr_zzendda ).
            obj_bee_zzendda->add( level = 2 element = obj_zzendda ).
            p_replacement_bee = obj_bee_zzendda.

          endif.

where reqtype is an attribute of iterator class of type string.

Many thanks for your time,

Anubhav.

Edited by: Anubhav Jain on Oct 16, 2008 10:02 AM

Former Member
0 Kudos

as from your starting question I think you have a 3 column table: a ddlb (between, on, from), and a a wrong input field got disabled when you switch from between to from. This should have been fixed with the javascript coding.

you might also try those functions:

function deactivate(name){
      document.getElementById(name).style.backgroundColor = 'lightgrey';
      document.getElementById(name).disabled = true;
      document.getElementById(name).value = '';
      
   }

   function activate(name){
      document.getElementById(name).style.backgroundColor = 'white';
      document.getElementById(name).disabled = false;
   }

Just tried the code in my table and the inputfield of a column can be disabled by

document.getElementById("tableviewid_ROW_COL").disabled = true;

Now you want to disable the calender popup help too?

Edited by: Michael Belz on Oct 15, 2008 9:43 AM

former_member184111
Active Contributor
0 Kudos

Hi Michael,

I implemented your idea completely , but mt table view is Multilineedit,so suppose i selected first row, selected FROM in DDLB , the third Inputfield goes disabled and bgcolor is also changed..everything seems to work fine but as soon as i select another row , a server event is trigered and all three cells in first row are also rendered again , hence the properties i set using JS are lost and despite of FROM in DDLB the third cell becomes enabled.

Code:

WHEN 'ZZREQUIRED'.


        IF p_edit_mode IS NOT INITIAL.
          DATA clientcall TYPE string.
          CONCATENATE 'c   h  e c k S election("' p_cell_id '");' INTO clientcall.


          DATA: required TYPE REF TO cl_htmlb_dropdownlistbox.

          required = cl_htmlb_dropdownlistbox=>factory( id = p_cell_id
                                                     table = m_required_ref
                                                  onc l i e n t  select    = clientcall
                                                  selection = m_row_ref->zzrequired
                                                  nameofkeycolumn = 'NAME'
                                                  nameofvaluecolumn = 'VALUE' ).

          p_replacement_bee = required .


        ENDIF.

in Layout:

fu n c t ion che c k Selection(cellid)
        {
            var req=dacument.g e t E l ementById(cellid).value;

            if ( r e q = =  ' FR  OM'||req = ='ON')
            {
            
              if (cel l  id=='service_1_1')
              {
              var ce l l name='service_1_3';
               
              }
             
              if (cel li  d=='service_2_1')
              {
              var c e l lname='service_2_3';
                            }

              if (cel  l id=='service_3_1)
              {
              var celln a me='service_3_3';
              }
                                   
              if (cell i d=='service_4_1')
              {
              var cel l name='service_4_3';
              }

              if (cell i d=='service_5_1')
              {
              var cell n ame='service_5_3';
              }
            }
             dacument.ge t E lementById(cellname).disabled=true;
    
        }

since i have only five visible rows in the Tv.

Hope i was able to explain my problem.

Thanks,

Anubhav.

Former Member
0 Kudos

what do you mean with 'ie'? the inputfield with the id 'service_1_8' is disabled and the user can't enter anything, isn't it?

former_member184111
Active Contributor
0 Kudos

Hi,

No that is not hapening and that is what i require.

The user can still enter value in the inputfield using the calender help popup or by typing in the date.

The input is greyed out.

I need to disable inputfield fully.

Thanks,

Anubhav.

Former Member
0 Kudos

all you need is this:

WHEN 'ZZREQUIRED'.


        data clientCall type string.
        concatenate 'checkSelection("' p_cell_id '");' into clientCall.

        p_replacement_bee = cl_htmlb_dropdownlistbox=>factory(
                              id                = p_cell_id
                              selection         = m_row_ref->VALUE
                              table             = me->m_value_ddl_ref
                              nameofkeycolumn   = 'NAME'
                              nameofvaluecolumn = 'VALUE'
                              onclientselect    = clientCall ).

the clientCall will look something like this:

checkSelection('tableviewname_1_1')

if you implement the function that way that it splits the argument by the '_' character you get row and column of the actual DDLB which triggered the event.

Fields which are not changed in the render_cell_start event are editable inputfields anyway...so no need to do anything here. The inputfields of a tableview automatically get the ids 'tableviewname_1_2' too (tableviewname_1_1 is the DDLB, row 1 col 2 is an inputfield for e.g.). So you can get the element with the getelementbyid and disable it regarding which col/row you are.

former_member184111
Active Contributor
0 Kudos

Hi Michael,

Modified the code in iterator as you told and added JS function to layout:

f u n c tion c  h eckSelection(cellid)
        {
            var req=docu m e n t . g e t E l e m e ntById(cellid).value;
            
            if (r e q=='FROM')
            {
            do c u m ent.getElementById('service_1_8').disabled=true;
            docum   e nt . g et E l e m e n t B yId('service_1_8').readonly=true;
            }
        }(hardcoded for testing only)

But it does not serves the purpose fully, the user can still select value from calender and make an entery although the text ie. date entered in inputfield is garyed out.

Can we restrict the user from making entery in the field ie. some how completely disable or freez the cell?

Thanks ,

Anubhav.

Former Member
0 Kudos

Use some javascript. Make use of the onClientSelect parameter for the DDLB in the iterator. Implement the checkSelection function in Javascript and get the actuel selected value of the DDLB. Check it and disable or enable the inputfields. This won't cause a roundtrip everytime you change the DDLB.

former_member184111
Active Contributor
0 Kudos

Hi Michael,

The code is:

Layout:

<htmlb:tableView id              = "service"
                                 headerText      = "Services"
                                 headerVisible   = "true"
                                 design          = "alternating"
                                 visibleRowCount = "5"
                                 fillUpEmptyRows = "true"
                                 onRowSelection  = "MyEventRowSelection"
                                 selectionMode   = "MULTILINEEDIT"
                                 width           = "950"
                                 filter          = "SERVER"
                                 iterator        = "<%= iterator %>"
                                 table           = "<%= itab_materials %>" />

IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS

APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.
    <def>-columnname = 'ZZREQUIRED'.
    <def>-title = '<center>Required</center>'.
    <def>-width = '100'.

    APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.
    <def>-columnname = 'ZZBEGDA'.
    <def>-title = '<center>From</center>'.
    <def>-width = '90'.

    APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.
    <def>-columnname = 'ZZENDDA'.
    <def>-title = '<center>To</center>'.
    <def>-width = '90'.

IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START

WHEN 'ZZREQUIRED'.


        IF p_edit_mode IS NOT INITIAL.

          DATA: required TYPE REF TO cl_htmlb_dropdownlistbox.

          required = cl_htmlb_dropdownlistbox=>factory( id = p_cell_id
                                                     table = m_required_ref

                                                  selection = m_row_ref->zzrequired
                                                  nameofkeycolumn = 'NAME'
                                                  nameofvaluecolumn = 'VALUE' ).

          p_replacement_bee = required .


        ENDIF.

      WHEN 'ZZBEGDA' .

        DATA: obj_fr_zzbegda TYPE REF TO cl_bsp_find_and_replace,
              obj_zzbegda TYPE REF TO cl_htmlb_inputfield,
              obj_bee_zzbegda  TYPE REF TO cl_bsp_bee_table.


        IF p_edit_mode IS NOT INITIAL.

          CLEAR : find , replace .

          find = '<input' .
          replace = `<input o n C h a  n g e = " i s i t T o d a y ( t h i s . v a l u e );"`.

          obj_fr_zzbegda = cl_bsp_find_and_replace=>factory( find = find
                                                              replace = replace
                                                              mode =  `FIRST_OCCURRENCE` ).



          obj_zzbegda = cl_htmlb_inputfield=>factory( id = p_cell_id type = 'date' showhelp = 'X' ).

          obj_zzbegda->value = m_row_ref->zzbegda.

          CREATE OBJECT obj_bee_zzbegda.
          obj_bee_zzbegda->add( level = 1 element = obj_fr_zzbegda ).
          obj_bee_zzbegda->add( level = 2 element = obj_zzbegda ).
          p_replacement_bee = obj_bee_zzbegda.


        ENDIF.

      WHEN 'ZZENDDA'.



        DATA: obj_fr_zzendda TYPE REF TO cl_bsp_find_and_replace,
        obj_zzendda TYPE REF TO cl_htmlb_inputfield,
        obj_bee_zzendda  TYPE REF TO cl_bsp_bee_table.


        IF p_edit_mode IS NOT INITIAL.

          CLEAR : find , replace .

          find = '<input' .
          replace = `<i n p u t   o n C h a n g e = " i s i t T o d a y ( t h i s  .v a l u e  );"`.

          obj_fr_zzendda = cl_bsp_find_and_replace=>factory( find = find
                                                              replace = replace
                                                              mode =  `FIRST_OCCURRENCE` ).



          obj_zzendda = cl_htmlb_inputfield=>factory( id = p_cell_id type = 'date' showhelp = 'X' ).

          obj_zzendda->value = m_row_ref->zzendda.

          CREATE OBJECT obj_bee_zzendda.
          obj_bee_zzendda->add( level = 1 element = obj_fr_zzendda ).
          obj_bee_zzendda->add( level = 2 element = obj_zzendda ).
          p_replacement_bee = obj_bee_zzendda.



        ENDIF.

Can you please throw some more light on your idea using above code...

Many thanks for the hint,

Anubhav.