Submit button being disabled if no changes are made to the editable grid

Under the grid, display a SAVE button. The button should be disabled by default.
If any changes are made to the grid (i.e. if a row is added, a row is removed, or data entered for a row is changed), the button should be enabled. After the button is clicked, it should become disabled again. Any help will be appreciated.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    in reply to RAHUL GANJI

    BTW, if any of my answers are helping you, I hope you'll click "Verify" on one or more of them in order to make sure I get credit :)

  • I have a grid which has fields for document,description,uploaded date,remove columns..

    I have a link at the bottom of the grid to attach the file using the file upload component.But Iam unable to show the instructions for the file upload component on file size that can be uploaded..

    Could you plz help me out how to do that

  • 0
    Certified Lead Developer
    in reply to RAHUL GANJI

    Field properties like Label and Instructions don't show up when used in an editable grid.  You could always make an extra column in the grid where you store information like max filesize, etc, or try putting a help tooltip on the column header with extra details like this.

  • the save button should disable if the file I have attached is above 5 MB(done with the validation code) and if I enter any description for the file in another field in the grid(editable)...

    The save button is disabled if I upload the file above 5MB but when I enter the description then the save button enables

    any input is appreciated

  • 0
    Certified Lead Developer
    in reply to RAHUL GANJI

    If you can share the relevant snippet of your current code (and maybe an accompanying screenshot) then that might help, otherwise I'd only be guessing as to what the issue is...

  • a!fileuploadField(
    label:"file upload",
    value:ri!file,
    validations:if(fv!file.size>5000000,"Attachments above 5 MB not allowed),
    saveInto:{ri!file,a!save(ri!saveDisable,false)}/*first i declared ri!saveDisabled as true*/
    ),
    if(isnull(ri!file),
    a!textField(
    label:"description",
    value:"",
    readOnly:true),
    a!textField(
    label:"description",
    value:ri!description,
    saveInto:{ri!description,a!save(ri!saveDisable,false),}))

  • 0
    Certified Lead Developer
    in reply to RAHUL GANJI

    Thanks for providing those.  I'm guessing your Save button is set to just be disabled when you have ri!saveDisabled set to true (though i'm not too sure what's going on since you're setting it to false in these saveIntos).

    Now that I think about it - while it is possible to validate based on the uploaded file's Size, I believe you won't be able to affect the Save button's enabled status based on the uploaded file's size, at least using "officially supported" functionality.

    So I would suggest you take a different approach for the value of your "saveDisable" value.  I would suggest you make it as a with() variable (or if 19.2 already, an a!refreshVariable inside a!localVariables set to refresh on referenced variable change).  For the moment I'll assume you're pre-19.2 and therefore use with() since it's simpler to explain.

    Declare a with() variable, local!disableSave, and set it to something like "isnull(ri!description)".  That way as soon as a description is entered, the Save button will be enabled.  Take for example the following code, which enables the SAVE button only when a document is uploaded and a description is entered (and throws a validation error when above 5MB is uploaded):

    load(
      local!document: null(),
      local!description: null(),
      
      with(
        local!disableSave: or(
          isnull(local!document),
          isnull(local!description)
        ), /* will update any time document or description are changed */
        
        a!sectionLayout(
          label: "Test Simple Document Upload",
          contents: {
            a!gridLayout(
              headerCells: {
                a!gridLayoutHeaderCell(label: "Document"),
                a!gridLayoutHeaderCell(label: "Description")
              },
              rows: a!gridRowLayout(
                contents: {
                  a!fileUploadField(
                    value: local!document,
                    saveInto: local!document,
                    description: local!description,
                    maxSelections: 1,
                    validations: {
                      if(
                        fv!files.size >  5 * 1024 * 1024,
                        "Attachments above 5MB are not allowed.",
                        null()
                      )
                    }
                  ),
                  a!textField(
                    value: local!description,
                    saveInto: local!description,
                    disabled: isnull(local!document)
                  )
                }
              )
            ),
            a!buttonArrayLayout(
              align: "CENTER",
              buttons: {
                a!buttonWidget(
                  label: "Save",
                  style: "PRIMARY",
                  disabled: local!disableSave
                )
              }
            )
          }
        )
      )
    )

  • From a related action,I have to manage some details of a record in grid by selecting it..When I select a record and proceed the details of that particular record is displayed with editable fields where I can make changes and save that form..But I want to navigate through all the records through the links called previous and next.When I click next I want to display the next records details in the editable fields on the form kind of thing and save it through that related action...Could you please input me with some details how to navigate to next record details without going to grid again and selecting it..