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
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
The method I described should still be sufficient I think. Or are you trying to recognize changes on a row-by-row basis? If you only have one SAVE button for the whole form (which was my assumption), then you shouldn't need to worry about this.
If I edit the description only the save button should be enabled and I should be able to save the changes
I think I couldnot do it this way
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
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
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),}))
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 ) } ) } ) ) )