Announcement

Collapse
No announcement yet.

again, multiple records form - discussion and selecting working row...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • again, multiple records form - discussion and selecting working row...

    hi guys,
    with the big help of jsb (he is really great ) I could get this work
    http://www.scriptcase.net/forum/show...color-and-lock!

    now i can ON AJAX ONCHANGE event to be able to change the background color and disable a field/fields... the trick is to specify the row counter that you are working on, otherwise any change in the field will disable/ change color of all the form (in multiple records) so it is useless...

    now, i have something like this:

    Code:
    If({field1} == '1')
    {
    sc_ajax_javascript('js_color_grey',array({row_cnt}));
    I have also a js method says:

    Code:
    var field1 = 'id_sc_field_field1_'+row_nr;
    document.F1[field1].style.backgroundColor = '#cccccc';
    add to that, the parameter of the js that i added "row_nr" and the new field that says row_cnt and the counter variable... just as jsb explained in my previous post...


    HOW about making this work onLoad? i tried the same and read in macros, found that this macro only works for ajax, how if i want to onLoad checks my field (fields) and apply those disable/background colors accordingly?

    i tried to create a php method and failed,

    i tried to use sc_field_disable it works fine on condition, but it disables all rows in the form, without being able to distanguish which row to work on...

    please, i need the form to also color/disable specific fields based on other fields conditions... not only on ajax on change...
    i mean in multiple records form, and to understand in which row that is applied...

    if i can further to set specifc option/data in some field based on other field selection, this will be really great

    all your help is appreciated guys, i know do annoy sometimes, believe me i am sure many of my level people will search for such stuff

  • #2
    onLoadRecord:
    If({field1} == '1')
    {
    sc_ajax_javascript('js_color_grey',array({row_cnt} )); //you actually don't need the row number in this case, but it doesn't hurt.
    }

    jsb

    Comment


    • #3
      perfect, just perfect... i almost swear that i tried it yesterday and didnt work, thought of ajax should stay in ajax events... hence, it can be called magic

      now even form has flexible stuff like grid

      thanks again, and always dear, appreciated your continuous support

      Comment


      • #4
        jsb, sorry to be so annoying, that really works fine for coloring but when disabling fields in the multiple records form case, i found this:
        1- coloring is fine, works ok as supposed to
        2- once "disable" is used in one of the fields, it is working as supposed, but, whenever the record is being updated (any other field in the row, or even if only selected the row and didn't change anything in it) then it is storing the value "0" to the database! which is inconvenience

        i changed all my primary keys of the tables that get the data from to id= "0" as the first record so some scenarios reset to 0 is actually helping because i am locking another field i the same row so i will make it as "0" in the db and that is fine,,,, but for most scenarios, i want to lock "disable" field not to be changed from 1 or 2 or 3 for example, alternatively, if i want it to be 0, then i am using "reload all other fields onChange by ajax or the last field of the row...) r

        So, in short, if row is saved and there is a disabled field in it, it will store it the value "0" to the database... and hence, as it is onLoadRecord, it is all messed up once the form is re-loaded... because that "ds" field which is supposed to be disabled and its value is 2, it is being 0... so there is another js_method makes it green color... and hence it is also enabled it for selection!! because it lost the condition if ({ds} == 0) { enable the the field, and make it green} and another condition says if ({ds} == 1) {condition here to make the field disable and make it white} + ({ds} == 2) {condition here to make the enabled and the color blue and make it white} -- every condition is in individual js_method as you thought me...

        i double checked all methods and and conditions, seems ok... when removed the "disable" functions from onLoadRecords then it works, but i want them really disabled and keep disabled if changed another values in the row!! not to be reset to 0 if they are disabled!

        hope you understand my issue and forgive my english... if you don't get my point, please tell me i will make some screenshots or explain it differently...

        Mike

        Comment


        • #5
          Oooops!
          Completely forgot that the value of a disabled select field is not submitted.
          So the easiest is to enabled them just before submitting the form.

          Click on Javascript in the Form Settings menu (left panel).

          Select the object: Form
          Select the event: Submit

          Click on Edit

          Put in the following code:

          var table = document.getElementById('hidden_bloco_0'); //table-id
          var r_count = table.rows.length; // number of records

          for(var i = 1; i < r_count; i++)
          {
          document.F1['id_sc_field_gsa_'+i].disabled = false;
          }

          Click on Update

          That should do it (I hope). :-)

          jsb

          Comment


          • #6
            hi dear, thank God you got my point without racking this time
            ok i tried the code and put it exact as is, what happens is the update button of the field is being disabled at all, the form as you know is in multiple record mode, and i am working on update mode.. so when selecting a row to update it, the button is inactive, no response at all!!
            jscodejsb.jpg
            i tried also to change the id_sc_field_gsa to id_sc_ds_gsa (the field in my case) but also, no response of the update button at all!

            if you hover on the update button by mouse, you get this in the browser (button-down-left)

            javascript: nm_atualiza('alterar');return false;

            we are so close jsb
            Last edited by MikeDE; 06-11-2014, 02:03 AM.

            Comment


            • #7
              jsb, here is what I'm stuck in right now, i tried also to add the method and enable those fields onBeforeUpdate using the same way but didn't work, it is keep sending the values as 0 to DB

              Comment


              • #8
                Sorry, it was late at night.

                instead of: document.F1['id_sc_field_gsa_'+i].disabled = false;

                it should be: document.F1['id_sc_field_ds_'+i].disabled = false;

                This code is only for {ds}, you have to add a line accordingly for every other select field of the row.

                jsb

                Comment


                • #9
                  LIFE SAVER

                  Comment


                  • #10
                    hi, sorry to open this thread again, just a small Q for jsbinca dude:

                    does this sc_ajax_javascript thing works on sc8? i have one to disable the form field onLoad record, doing exactly as it was in sc7 but doesn't work in sc8.. in fact, i have 2 sc_ajax_javascript that makes the fields of the multiple records form 1-change color, 2- disable them in case one of them has the value== "0" but only first row of the form is affected... loading with correct color... disable ok... other rows all doesn't affect! what could be wrong!? i have the row_cnt field as we did earlier in SC7

                    Comment


                    • #11
                      okay, investigating this further, seems sc_ajax_javascript thing works onLoadRecord of my multiple-records form but for some reason it does work for one field and doesn't work for the other!!

                      this:

                      If({ds} == '0')
                      {
                      sc_ajax_javascript('js_fields_enable',array({row_c nt}));
                      }

                      but this:

                      If({dx} == '0')
                      {
                      sc_ajax_javascript('js_field_du_color_red',array({ row_cnt}));
                      }

                      doesn't work! doesn't make sense,
                      the first one works ok if the second is not in the same event (onLoadRecord)
                      if i put the second one only, doesn't work at all!
                      if put both on same event (onLoadRecord) - first work fine but disables the first row only as it matches the criteria (ds=0 then disable the row firleds) and then stops... doesn't apply for the other records
                      the last field of the record is {dx} if is 0 then stops even the first criteria.. if it is dx=1 then the first criteria is applied until the seond row which has dx=0

                      hope i could explain it.... i did change and double checked everything... nothing seems wrong or different that the SC7 version..

                      any hint?

                      Comment


                      • #12
                        this is really driving me crazy... the js_method parameter (row_nr) sometimes i click on the js_method to check the code but shows no row_nr paramerter, click again or refresh or logout and login, it shows the row_nr there but doesn't work through... only for this stupid field... removed the method and re-created many times, no use,, also created new one with other name and called within onLoadRecord, no use grrrrrrrr is it a bug? i'm using sc8..09 of the 9/19/2014

                        Comment


                        • #13
                          Even if it seems to work (partially), a javascript call is not supposed to work in the onLoadRecord event (see Events x Applications in the docu).
                          Whatever you want to accomplish, you have to think of a different approach.

                          jsb

                          Comment


                          • #14
                            hi jsb,

                            i have 3 fields, if field1 == 0 i have the this:

                            sc_ajax_javascript('js_field_field1_color_red',arr ay({ row_cnt}));

                            and if field2 == 0 again
                            sc_ajax_javascript('js_field_field2_color_red',arr ay({ row_cnt}));

                            these works fine, but the last one doesn't work, even it is exactly as the obove fields, nothing changed
                            i checked the documentation, the sc_ajax_javascript doesn't they say do not work onLoardRecord but it works for 2 fields!! i checked for test another field and again it is working.. only one field doesn't, that is strange

                            also in SC7 was working fine, doesn't say in documentation it must work, but it works normally even the 3 fields though, you gave me this way to color and disable the fields as when loading the multiple records form when we put the row_cnt virtual field and counter =1 in the scriptinit.. hope you remember

                            any hint or alternative way to solve this with SC8 is highly appreciated... I'm yet trying to about to become crazy, just wanna know why


                            Mike

                            Comment


                            • #15
                              Hi,
                              that's really strange. I can't tell you why it works on all fields but one. There must be something different with this field then.
                              I know I suggested this solution knowing that the macro wasn't supposed to work, but as you experienced as well, it does in SC7.
                              I don't use SC8 for production, just for testing/playing around...still too much trouble.

                              jsb

                              Comment

                              Working...
                              X