cancel
Showing results for 
Search instead for 
Did you mean: 

using JS for inputfield inTV iterator.

former_member184111
Active Contributor
0 Kudos

Hi ,

Below is the code of IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START:

WHEN 'DATE' .

      IF p_edit_mode IS NOT INITIAL.


        DATA: dateon TYPE REF TO cl_htmlb_inputfield .
        dateon  = cl_htmlb_inputfield=>factory( id = p_cell_id id_postfix = '_sixth'
        type = 'date'
        showhelp = 'X').

        p_replacement_bee = dateon.
        dateon->value = m_row_ref->date.

      ENDIF.

How can i add JS validation for checking that the date is Equall to or Less than current date..for the inputfield above..

Any clue will be of great help...

Thanks,

Anubhav.

Edited by: Anubhav Jain on Oct 1, 2008 12:31 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

raja_thangamani
Active Contributor
0 Kudos

in the IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START method add the following code.


data: v_cel_val type string.

 WHEN 'DATE' .
 
      IF p_edit_mode IS NOT INITIAL.
 
 ONCATENATE 'javascript:CheckDate(' m_row_ref->date ')' into v_cel_val. 
 
        DATA: dateon TYPE REF TO cl_htmlb_inputfield .

        dateon  = cl_htmlb_inputfield=>factory( id = p_cell_id id_postfix = '_sixth'
        type = 'date'
        value = m_row_ref->date
        onClientClick = v_cel_val
        showhelp = 'X').
  
        p_replacement_bee = dateon.
         dateon->value = m_row_ref->date.
 
      ENDIF.

Now in layout, you can write the date validation check in JS CheckDate() function. Google to get the date check javascript code.

Hope this will solve your problem.

Raja

former_member184111
Active Contributor
0 Kudos

Hi Raja,

I guess thers no attribute as

onClientClick

for method FACTORY of class CL_HTMLB_INPUTFIELD .

Thanks,

Anubhav.

raja_thangamani
Active Contributor
0 Kudos

Try below code. It should work.


data: v_cel_val type string.
 
 WHEN 'DATE' .
 
      IF p_edit_mode IS NOT INITIAL.
 
 ONCATENATE 'javascript:CheckDate(' m_row_ref->date ')' into v_cel_val. 
 
p_replacement_bee = cl_htmlb_inputfield=>factory(
id = p_cell_id
MAXLENGTH = '12'
size = '12'
WIDTH = '80'
value = m_row_ref->date
type = 'date'
onClientClick = v_cel_val
showhelp = 'X'
cellvalue = 'TRUE' ).

Raja

former_member184111
Active Contributor
0 Kudos

Hi Raja,

I tried, but getting error "Fromal parameter OnCleintClick does not exis"

I guess , bsp find and replace will help..but i dont know how to use it..in iterator

Thanks a lot,

Anubhav Jain.

raja_thangamani
Active Contributor
0 Kudos

Try

 onValueHelp = v_cel_val 

but not sure it will affect you date popup help. Pls give a try & let me know.

Raja

former_member184111
Active Contributor
0 Kudos

Hi Raja,

The script is working , the calendar is not coming...is there any other way?

Got the solution in another thread:

Thanks,

Anubhav.

Edited by: Anubhav Jain on Oct 6, 2008 11:28 AM

raja_thangamani
Active Contributor
0 Kudos

Can you share the solution which you found. It might help others.

Raja

former_member184111
Active Contributor
0 Kudos

Hi Raja,

Found the code ;

method if_htmlb_tableview_iterator~render_cell_start .
  data: o_fr type ref to cl_bsp_find_and_replace,
       o_ip type ref to cl_htmlb_inputfield,
       o_bee  type ref to cl_bsp_bee_table.
  data: find type string.
  data: replace type string.
  data: rowno type string ,
        columnno type string ,
        tvid type string .
  clear: find, replace .
 
  case p_column_key.
 
    when 'CARRID'.
      clear : rowno, columnno, tvid .
      split p_cell_id at '_' into tvid rowno columnno .
 
      find = '< i n p u t ' .
      replace = `< i n p u t   o n C h a n g e = " j a v a s c r i p t : a l e r t ( t h i s. n a m e ) ; " ` .
 
      o_fr = cl_bsp_find_and_replace=>factory( find = find
                                                          replace = replace
                                                          mode =
 
      `FIRST_OCCURRENCE` ).
 
      o_ip = cl_htmlb_inputfield=>factory( id = p_cell_id ).
      create object o_bee.
      o_bee->add( level = 1 element = o_fr ).
      o_bee->add( level = 2 element = o_ip ).
      p_replacement_bee = o_bee.
  endcase .
 
endmethod.

in a previous post by Durairaj.

Thanks for the help,

Anubhav.