1 2 Previous Next 17 Replies Latest reply: May 23, 2012 3:50 AM by VC RSS

    Tabular form editable row

    jmniard
      hi ,
      i work on apex 4.1.1.00.23.
      Imagine that i have a column name "EDITABLE' that return 1 or 0.

      - 1 gives the row editable
      - 0 gives the row no editable
      I would like to know if it's possible to enable edit/disable edit the rows based of this column value .

      Best regards
      jean marc
        • 1. Re: Tabular form editable row
          VC
          Best way to do this is creating a Manual Tabular form

          http://deneskubicek.blogspot.co.uk/2008/04/manual-tabular-form.html
          • 2. Re: Tabular form editable row
            jmniard
            thanks for your answer, but i look for a simplier solution.
            i have seen that we can change the color of a row based on column value( use template) , instead of this color attribute, does an editable attibute exist ?

            best regards
            jean marc
            • 3. Re: Tabular form editable row
              VC
              That's why I mentioned my previous as Best way

              You can always disable it via JavaScript/jQuery

              example on f01 column, but replace with your column number
              jQuery.each($('input[name="f01"]'), function() {
                    alert($(this).attr("name")+' - '+$(this).val());
                  // here you can set the readonly attribute like this
                 if ($(this).val()==1) {
                 $(this).attr("readonly",true)
                 }
              });
              • 4. Re: Tabular form editable row
                jmniard
                thanks your answer, i have a stupid question, where in tabular form i put your code ?

                best regards
                jean marc
                • 5. Re: Tabular form editable row
                  VC
                  Either you need to run this on page load inside script tags

                  Edit page > HTML Header
                  <script>
                   jQuery.each($('input[name="f01"]'), function() {
                         alert($(this).attr("name")+' - '+$(this).val());
                       // here you can set the readonly attribute like this
                      if ($(this).val()==1) {
                      $(this).attr("readonly",true)
                      }
                   });
                  </script>
                   
                  • 6. Re: Tabular form editable row
                    jmniard
                    i try your code, i suppose the name is f0x and x the column number

                    i put the code in the page HTML Header,
                    i haven't the dialog box generated by your alert, and the field remains a textfield.
                    I remove the condition

                    <script>
                    jQuery.each($('input[name="f02"]'), function() {
                    alert($(this).attr("name")+' - '+$(this).val());
                    // here you can set the readonly attribute like this

                    $(this).attr("readonly",true)

                    });
                    </script>
                    • 7. Re: Tabular form editable row
                      VC
                      jmniard wrote:
                      i try your code, i suppose the name is f0x and x the column number

                      i put the code in the page HTML Header,
                      i haven't the dialog box generated by your alert, and the field remains a textfield.
                      I remove the condition

                      <script>
                      jQuery.each($('input[name="f02"]'), function() {
                      alert($(this).attr("name")+' - '+$(this).val());
                      // here you can set the readonly attribute like this

                      $(this).attr("readonly",true)

                      });
                      </script>
                      you are right, wrap the code in $(document).ready....
                      • 8. Re: Tabular form editable row
                        jmniard
                        hello ,
                        i have a little problem,
                        i try to find the syntax to get the value of the column 13 with the ($("f13").val()==1) but it doesn't work
                        as following :

                        <script type="text/javascript">
                        $(document).ready(function(){
                        jQuery.each($('input[name="f02"]'), function() {


                        if ($("f13").val()==1) {

                        $(this).attr("readonly",true);
                        $(this).css("background-color", "yellow");
                        }


                        });


                        });

                        </script>

                        can someone give the correct syntax
                        • 9. Re: Tabular form editable row
                          VC
                          jmniard wrote:
                          hello ,
                          i have a little problem,
                          i try to find the syntax to get the value of the column 13 with the ($("f13").val()==1) but it doesn't work
                          as following :

                          <script type="text/javascript">
                          $(document).ready(function(){
                          jQuery.each($('input[name="f02"]'), function() {
                          Here you need to replace f02 with f13
                          >
                          if ($("f13").val()==1) {
                          This is not correct syntax
                          $(this).attr("readonly",true);
                          $(this).css("background-color", "yellow");
                          }


                          });


                          });

                          </script>

                          can someone give the correct syntax
                          try this
                          <script type="text/javascript">
                           $(document).ready(function(){
                           jQuery.each($('input[name="f13"]'), function() {
                           
                               if ($(this).val()==1) {
                          
                               $(this).attr("readonly",true);
                              $(this).css("background-color", "yellow"); 
                              }
                           
                           
                          });
                          });
                          </script>
                          Look at this to understand about jQuery Selectors http://api.jquery.com/category/selectors/
                          • 10. Re: Tabular form editable row
                            jmniard
                            thanks VC
                            but the problem is that i want to modify the attributes(backgroundcolor,readonly) of the column 2 based on the value of the column 13.

                            regards
                            jean marc
                            • 11. Re: Tabular form editable row
                              VC
                              Then Do this
                              <script type="text/javascript">
                               $(document).ready(function(){
                                // loop through the actual f02 item
                               jQuery.each($('input[name="f02"]'), function(index) {
                              
                                    // check the value of f13 column at that row
                                 if ($('input[name="f13"]')[index].val()==1) {
                               
                                   $(this).attr("readonly",true);
                                  $(this).css("background-color", "yellow"); 
                                  }
                                
                              });
                              });
                              </script>
                              • 12. Re: Tabular form editable row
                                jmniard
                                i try your code with no success, no alert dialog appear

                                <script type="text/javascript">
                                $(document).ready(function(){
                                // loop through the actual f02 item
                                jQuery.each($('input[name="f02"]'), function(index) {


                                alert($('input[name="f13"]')[index].val());


                                });
                                });
                                </script>
                                • 13. Re: Tabular form editable row
                                  VC
                                  <script type="text/javascript">
                                   $(document).ready(function(){
                                  
                                   jQuery.each($('input[name="f13"]'), function(index) {
                                  
                                        // check the value of f13 column at that row
                                     if ($(this).val()==1) {
                                   
                                       $('input[name="f02"]')[index].attr("readonly",true);
                                      $('input[name="f02"]')[index].css("background-color", "yellow"); 
                                      }
                                    
                                  });
                                  });
                                  </script>
                                  try this
                                  • 14. Re: Tabular form editable row
                                    jmniard
                                    the line $('input[name="f02"]')[index].attr("readonly",true);
                                    doesn't seem to be recognize

                                    <script type="text/javascript">
                                    $(document).ready(function(){

                                    jQuery.each($('input[name="f13"]'), function(index) {

                                    // check the value of f13 column at that row
                                    alert(index);
                                    if ($(this).val()==1) {

                                    $('input[name="f02"]')[index].attr("readonly",true);
                                    // $('input[name="f02"]')[index].css("background-color", "yellow");
                                    }

                                    });
                                    });
                                    </script>
                                    1 2 Previous Next