Skip to main content
josemanuelo0002
March 14, 2023
Solved

How to display files in a grid with details?

  • March 14, 2023
  • 12 replies
  • 0 views

Hi,

I found a code that explain how to display files in a grid, but my problem is that I can't create new columns with more information, for example the Description of the file. Please, can you give an advice?

This is my currect code. Thanks a lot.

load(
local!data: {
{
id: 1,
folderId: 4768/* Folder ids*/

},
{
id: 2,
folderId: 4947/* Folder ids*/

}
},
a!gridLayout(
label: "Documentación",
labelPosition: "ABOVE",
headerCells: {
a!gridLayoutHeaderCell(
label: "Nombre documento"
)
},
columnConfigs: {},
rows: {
a!forEach(
items: local!data,
expression: a!gridRowLayout(
id: fv!index,
contents: a!richTextDisplayField(
value: a!forEach(
items: folder(
index(
fv!item,
"folderId",
{}
),
"documentChildren"
),/*Getting documents from folder*/
expression: {
a!richTextItem(
text: document(
fv!item,
"name"
),
link: a!documentDownloadLink(
document: fv!item
)
),
a!richTextItem(
text: char(10),
showWhen: not(
fv!isLast
)
)
}
)
)
)
)
},
selectionSaveInto: {},
validations: {},
shadeAlternateRows: true
)
)

Best answer by sanchitg0002

It's because you are not passing gridRowLayout contents in an array

12 replies

stefanhelzle0001
Brainy
March 14, 2023

Just add more fields to the contents parameter of your gridRowLayout() like you would do with any other grid.

And next time, please ...

josemanuelo0002
March 14, 2023

Thanks! I change it

mallepup3914
March 14, 2023

Hi josemanuelo0002

As you are displaying data in grid, you can add new columns and you can map the document description for each doc.

Participating Frequently
March 14, 2023
but my problem is that I can't create new columns with more information

Can you please elaborate.

mallepup3914
March 14, 2023

You can use document() where it can show the Description of the Document, that you can display in the required column.

harshitb6843
March 14, 2023

The problem here is that you will need to again query all the documents in other column and then use document() function on it. 
You don't have those documents as part of your data subset. So either you add it in your data or you query the folder again to get a list of documents. 

josemanuelo0002
March 14, 2023

This is my code with the Description column and I recieve an error message:

load(
            local!data: {
              {
                id: 1,
                folderId: 4768/* Folder ids*/

              },
              {
                id: 2,
                folderId: 4947/* Folder ids*/

              }
            },
            a!gridLayout(
              label: "Documents",
              labelPosition: "ABOVE",
              headerCells: {
                a!gridLayoutHeaderCell(
                  label: "Name"
                ),
                a!gridLayoutHeaderCell(
                  label: "Description"
                )
              },
              columnConfigs: {},
              rows: {
                a!forEach(
                  items: local!data,
                  expression: a!gridRowLayout(
                    id: fv!index,
                    contents: 
                    a!richTextDisplayField(
                      value: a!forEach(
                        items: folder(
                          index(
                            fv!item,
                            "folderId",
                            {}
                          ),
                          "documentChildren"
                        ),/*Getting documents from folder*/
                        expression: {
                          a!richTextItem(
                            text: document(
                              fv!item,
                              "name"
                            ),
                            link: a!documentDownloadLink(
                              document: fv!item
                            )
                          ),
                          a!richTextItem(
                            text: char(10),
                            showWhen: not(
                              fv!isLast
                            )
                          )
                        }
                      )
                    ),
                    a!richTextDisplayField(
                      value: a!forEach(
                        items: folder(
                          index(
                            fv!item,
                            "folderId",
                            {}
                          ),
                          "documentChildren"
                        ),/*Getting documents from folder*/
                        expression: {
                          a!richTextItem(
                            text: document(
                              fv!item,
                              "description"
                            )
                          ),
                          a!richTextItem(
                            text: char(10),
                            showWhen: not(
                              fv!isLast
                            )
                          )
                        }
                      )
                    )
                  )
                )
              },
              selectionSaveInto: {},
              validations: {},
              shadeAlternateRows: true
            )
          )

March 14, 2023

It's because you are not passing gridRowLayout contents in an array