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

Parents
  • 0
    Certified Lead Developer

    Set a LOAD variable (or if on 19.2, a localVariable with no autorefresh) equal to the original value of the data used to populate the grid.  Then set a with / autorefreshing variable that compares the original data with the current data, which evaluates to (for example) true() if changes have been made.  Use that variable to help determine the state of the SAVE button.  And finally, when SAVE is clicked, you would by some means cause the "original value" variable to be updated with the current data.

  • I actually have a column as editable--text which iam saving if any editing to the description column also...How can I recognise those changes made to each row and enable the save button based on that

  • 0
    Certified Lead Developer
    in reply to RAHUL GANJI
    No I dont want the button to be enabled if the user doesnot actually makes changes

    the code I've suggested handles this.

    and also how can I check with the documents being duplicated...dont want to upload a new document if it already exists

    Appian treats all uploaded files as unique IDs - it has no direct way of knowing whether two different files are identical, though you could add a validation to your upload which checks whether the uploaded file name and size (for example) are identical to a previously uploaded file.

  • Mike ,

    I have a relation action shortcut on a record summary 

    When I perform "Delete Record" related action ,the record successfully gets deleted through a process model without activity chaining but after deletion it returns back to the Summary dashboard instead of the Record grid view...How can I handle this? 

  • 0
    Certified Lead Developer
    in reply to RAHUL GANJI

    There's no easy way to do this that I know of.  One of the only suggestions I have might be, after the deletion is completed, have the user chain forward into a user input task that has no Submit button - and on that task, show a record link with the record type set but no record identifier - i believe this will cause them to be linked to the record listing when they click it.  (The task would need to time out after a few minutes to end the process in the background.)  The text for the link could say something like, "Click here to return to Record Listing", along with some explanation that the record has now been deleted and to not try clicking back to "summary" etc.

  • 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
                )
              }
            )
          }
        )
      )
    )

Reply
  • 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
                )
              }
            )
          }
        )
      )
    )

Children
No Data