How to create an editable grid from a record

Hi! I have a doubt with the approach of my application and I would like to know your thoughts!

In my case, I have a summary view of PO in which I have a read-only grid with the PO lines.

I created a related record action to "recepit" the PO Lines ("Recepcionar Pedido", which will link to a process model), and now I want to create an interface with the following conditions:

  • 1) I must show the same information/table with the PO Lines (I just need some of the fields). Not need to add new rows
  • 2) I must be able to create an extra-column to introduce manually 

In order to do this, I thought several options:

  • 1) Create an editable grid based on the data of a record (like a read-only grid, same values, but with the posibility to manipulate it)
  • 2) Convert the read-only grid in an editable grid (i dont know if its possible or complex, I know the configuration are totally different)

How can I manage to do it? If it´s not a good approach, I would like to hear from your recommendations 

Thanks a lot, any idea would be useful

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi Carlos, 

    What do you mean with "I must be able to create an extra column to introduce manually". Do you mean that the final user will have the possibility to add manually a column to the grid? Or you mean you as developer will add a new column to the grid? What type of data will be managed in that new column? 

  • Hi Ignacio! In this case, I mean that I, as a developer, must have the chance to add a new column to the grid (NOT the user). 

    Each row of my previous grid had a column/field called "quantity". In my new grid, I would like to create a new column called "Quantity Receipt" (just a number the user introduces manually)

    But this is my second step. First of all, I would like to "query" or "translate" my data to the new editable grid. How can I manage this? Can I make a query in my editable grid instead of creating it from zero?

    *Update: I was searching ways to pass the data of my read only grid, and I have shown a post in which selectable values are used. What do you think about this approach to save the data? Logically after that I have to show a grid again (and being able to add a column as a developer)

    In Mike´s explanation, I´m interested in the part of making an edit of the existing data after clicking the link/selected rows. I would like to understand how to do this (passing the data and make it editable)

Reply
  • Hi Ignacio! In this case, I mean that I, as a developer, must have the chance to add a new column to the grid (NOT the user). 

    Each row of my previous grid had a column/field called "quantity". In my new grid, I would like to create a new column called "Quantity Receipt" (just a number the user introduces manually)

    But this is my second step. First of all, I would like to "query" or "translate" my data to the new editable grid. How can I manage this? Can I make a query in my editable grid instead of creating it from zero?

    *Update: I was searching ways to pass the data of my read only grid, and I have shown a post in which selectable values are used. What do you think about this approach to save the data? Logically after that I have to show a grid again (and being able to add a column as a developer)

    In Mike´s explanation, I´m interested in the part of making an edit of the existing data after clicking the link/selected rows. I would like to understand how to do this (passing the data and make it editable)

Children
  • 0
    Certified Lead Developer
    in reply to carlosp5114

    Hi Carlos, 

    to add this link, and then display a new field below the grid, you should add a dynamic link in a new column of the read only grid and then this dynamic link will save a boolean to true which is also in the "showWhen" attribute of the new field below your grid, so when you press the link the field is shown.

    But then you also need to save the item where you are going to save the value quantity and you must think in a solution for this. 

    On my side, I prefer creating an editable grid, where you will add the new editable column with a text field and in each field you will save the quantity of each row. The data for this grid should be fetched again as you did in the parent interface. 

  • Thanks Ignacio! I´m trying to go with the editable grid, but I´m having some trouble

    First of all, I queried my data and saved it in a local variable to display in the grid (ok)

    Now, I have to save the values in the new localvariable/ruleinput/record, but I´m not sure how to do this (until now, I used the fv!item...[] in "value" and "saveInto" because I needed user interaction, but for this data I don´t need it except of the new column I want to create).

    I mean, I don´t know how can I point to my local!data (I suppose it is not correct to use fv! item) and then, without interaction , save the values (¿to a new local variable? Directly to a rule input?)

    I don´t know how to add an empty extra column to my local variable too

    I leave my code here for any considerations, what I´m trying to do is something like in the lines 53 and 55 (value from data, save into another record). Thanks a lot!

    a!localVariables(
      /*mirar para incluir columna extra en variable local*/
      local!DatosLineas: a!queryRecordType(
        recordType: 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido',
        fields: {
          'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{fcfa4b36-4398-4430-8055-ecfa59daf13a}idLineaPedido','recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material','recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'
        },
        filters: a!queryFilter(
          field: 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido',
          operator: "=",
          value: ri!record['recordType!{3c95c0e4-e69d-43f6-b485-e72b24252af7}CPF Maestro Pedidos.fields.{7309402c-2312-4a4e-bdaa-5654789bffb2}idPedido']
        ),
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
      ).data
      ,
      
      {
        a!sectionLayout(
          label: "Líneas Recepción",
          labelIcon: "list-alt-solid",
          contents: {
            a!gridLayout(
              label: "A continuación, introduzca las cantidades a recepcionar para cada línea de pedido y pulse el botón de Recepción",
              headerCells: {
                a!gridLayoutHeaderCell(label: "Linea Pedido"),
                a!gridLayoutHeaderCell(label: "Pedido"),
                a!gridLayoutHeaderCell(label: "Material"),
                a!gridLayoutHeaderCell(label: "Cantidad"),
                a!gridLayoutHeaderCell(label: "Precio Unitario"),
                a!gridLayoutHeaderCell(label: "Importe Total"),
                a!gridLayoutHeaderCell(label: "Cantidad Recepcionada"),
                a!gridLayoutHeaderCell()
              },
              columnConfigs: {
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
                a!gridLayoutColumnConfig(width: "ICON")
              },
              rows: a!forEach(
                items: local!DatosLineas,
                expression: a!gridRowLayout(
                  contents: {
                    a!textField(
                      value: fv!index,
                      readOnly:true
                    ),
                    a!textField(
                      value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'],
                      saveInto: {
                        fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'],
                        a!save(fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{4c08ec47-3ddd-462c-bbf5-d5d4a849be75}ConcatPedidoMaterial'], concat(
                          fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'],
                          "-",
                          fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material']
                        ) 
                        )
                        ,
                        a!save(ri!recordLineasRecep['recordType!{20fd7d81-a6d6-4fee-9219-afab0a7df2e4}CPF Lineas Recepciones.fields.{c78be956-74b8-47a7-b154-4e167785756d}idPedido'], fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'])
                      }
                    ),
                  
                    a!textField(
                      value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material'],
                      saveInto: {
                        fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material'],
                        a!save(fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{4c08ec47-3ddd-462c-bbf5-d5d4a849be75}ConcatPedidoMaterial'], concat(
                          fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{71427dbb-12db-4f83-bd99-f625bf9af271}idPedido'],
                          "-",
                          fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material']
                        ) 
                        ),
                        a!save(ri!recordLineasRecep['recordType!{20fd7d81-a6d6-4fee-9219-afab0a7df2e4}CPF Lineas Recepciones.fields.{5e36f0f0-c022-4883-bc2c-195b92a6b9e0}Material'], fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{69e9a834-b2fb-4f35-a36d-3c526c97f4ac}Material'])
                        
                      }
                    ),
                    a!integerField(
                      value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'],
                      saveInto: {
                        fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'],
                        a!save(
                          fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'],
                          if(
                            or(
                              isnull(
                                fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad']
                              ),
                              isnull(
                                fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit']
                              )
                            ),
                            0,
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] * fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit']
                          )
                        )
                      },
                      required: true,
                      validations: {
                        if(
                          a!isNotNullOrEmpty(
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad']
                          ) = false,
                          "",
                          if(
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] < 1,
                            "La cantidad debe ser superior a cero",
                            ""
                          )
                        )
                      }
                    ),
                    a!floatingPointField(
                      value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'],
                      saveInto: {
                        fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'],
                        a!save(
                          fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'],
                          if(
                            or(
                              isnull(
                                fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad']
                              ),
                              isnull(
                                fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit']
                              )
                            ),
                            0,
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] * fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit']
                          )
                        )
                      },
                      required: true,
                      validations: {
                        if(
                          a!isNotNullOrEmpty(
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit']
                          ) = false,
                          "",
                          if(
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit'] < 0,
                            "El precio unitario debe ser superior a cero",
                            ""
                          )
                        )
                      }
                    ),
                    a!floatingPointField(
                      value: if(
                        or(
                          isnull(
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad']
                          ),
                          isnull(
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit']
                          )
                        ),
                        0,
                        fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{e78c5b35-026f-4713-8404-05077c6c9152}Cantidad'] * fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{47f4bf32-2e41-4c5a-a7e7-9fc7786bd753}PrecioUnit']
                      ),
                      saveInto: {
                        fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe']
                      },
                      required: true,
                      validations: {
                        if(
                          a!isNotNullOrEmpty(
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe']
                          ) = false,
                          "",
                          if(
                            fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{beb59a89-a332-46d3-b718-a8285f58f942}Importe'] < 0,
                            "El importe debe ser superior a cero",
                            ""
                          )
                        )
                      },
                      align: "RIGHT"
                    ),
                    a!integerField(
                      value: fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{bd0fe4ca-322c-422e-89e5-97e5194817a1}CantRecepAcum'],
                      saveInto: {
                        fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{bd0fe4ca-322c-422e-89e5-97e5194817a1}CantRecepAcum']
                        , a!save(ri!recordLineasRecep['recordType!{20fd7d81-a6d6-4fee-9219-afab0a7df2e4}CPF Lineas Recepciones.fields.{5b2d9770-999d-481c-927b-a2d7fc000098}CantidadRecep'], fv!item['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{bd0fe4ca-322c-422e-89e5-97e5194817a1}CantRecepAcum'])
                      }
                      ),
    
                    a!richTextDisplayField(
                      value: {
                        a!richTextIcon(
                          icon: "times-circle",
                          link: a!dynamicLink(
                            value: remove(local!DatosLineas, fv!index),
                            saveInto: local!DatosLineas
                          ),
                          linkstyle: "STANDALONE",
                          color: "NEGATIVE"
                        )
                      }
                    )
                  }
                )
              )
            )
          }
        ),
        a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Completar Recepción",
              saveInto: a!save(
                /*cambiar por recordLineasRecepciones*/
                ri!recordLineasRecep,
                local!DatosLineas
              ),
              submit: true,
              style: "PRIMARY",
              validate: true
            )
          },
          secondaryButtons: {
            a!buttonWidget(
              label: "Cancelar",
              value: true,
              saveInto: ri!cancel2,
              submit: true,
              style: "NORMAL",
              validate: false
            )
          }
        )
      }
    )