Skip to main content
syedh1346
July 20, 2023
Question

add rows to the grid dynamically

  • July 20, 2023
  • 4 replies
  • 0 views

Hi All,


I'm creating an application where I have a form with an add button on it. Using this button, I want to add a row into an editable grid with recently added data. Then, using the same form, I want to add the data in the same Editable Grid in the next row. Finally, if the user clicks the submit button, all the grid data is stored in the database.


Adding a row to the grid when I click the add button here I am facing the problem

    4 replies

    stefanhelzle0001
    Brainy
    July 20, 2023

    What specific problem do you have? Did you follow the grid interface recipes?

    docs.appian.com/.../SAIL_Recipes.html

    syedh1346
    syedh1346Author
    July 20, 2023

    I want to use a grid view to show the data that was entered into the form. before submit 

    stefanhelzle0001
    Brainy
    July 20, 2023

    Here we trade tips for details! Maybe this helps.

    stackoverflow.com/.../how-to-ask

    konduruc733182
    July 21, 2023

    Hello syedh1346,

    is it just an editable grid where you want to add data? If so the below will help

     

    {
      a!gridLayout(
        label: "Editable Grid",
        labelPosition: "ABOVE",
        headerCells: {
          a!gridLayoutHeaderCell(label: "S.No"),
          a!gridLayoutHeaderCell(label: "Name"),
          a!gridLayoutHeaderCell(label: "Date"),
          a!gridLayoutHeaderCell(label: "")
        },
        columnConfigs: {
          a!gridLayoutColumnConfig(
            width: "ICON"
          ),
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE"
          ),
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE"
          ),
          a!gridLayoutColumnConfig(
            width: "ICON"
          )
        },
        rows: a!forEach(
          items: ri!data,
          expression: a!gridRowLayout(
            contents: {
              a!textField(value: fv!index,readOnly: true),
              a!textField(
                value: fv!item.employeeName,
                saveInto: fv!item.employeeName,
                required: true
              ),
              a!dateField(
                value: fv!item.employeeJoiningDate,
                saveInto: fv!item.employeeJoiningDate,
                required: true
              ),
              a!richTextDisplayField(
                value: a!richTextIcon(icon: "times",color: "NEGATIVE",link: a!dynamicLink(value: null,saveInto: a!save(ri!data,remove(ri!data,fv!index))),linkStyle: "STANDALONE")
              )
            }
          )
        ),
        addRowLink: a!dynamicLink(
          label: "Add row",
          value: null,
          saveInto: a!save(
            ri!data,
            append(ri!data,'type!{urn:com:appian:EMPLOYEE}EMPLOYEE_DETAILS'())
          )
        ),
        selectionSaveInto: {},
        validations: {},
        shadeAlternateRows: true
      ),
      a!buttonLayout(
        primaryButtons: a!buttonWidget(
          label: "Submit",
          value: true,
          submit: true,
          validate: true
        )
      )
    }