Question
Showing excel data in editable grid
I am trying to show Student Data in editable grid through excel with marks in subjects. there is a field with total marks which is depend on marks from other fields. Problem is i am able to when i change marks of any subject changes get reflect in the MarksObtained field which is the sum of marks of all subjects but when i submit it does not store the changed data in Marksobtained field. it stores the original data which is in excel file.
a!localVariables(
a!formLayout(
label: "Student Details",
contents: {
a!sectionLayout(
contents: {
a!gridLayout(
label: "Editable Grid",
labelPosition: "ABOVE",
headerCells: {
a!gridLayoutHeaderCell(label: "RollNumber"),
a!gridLayoutHeaderCell(label: "FullName"),
a!gridLayoutHeaderCell(label: "Hindi"),
a!gridLayoutHeaderCell(label: "English"),
a!gridLayoutHeaderCell(label: "Maths"),
a!gridLayoutHeaderCell(label: "Physics"),
a!gridLayoutHeaderCell(label: "Chemistry"),
a!gridLayoutHeaderCell(label: "ObtainedMarks"),
/*a!gridLayoutHeaderCell(label: "TotalMarks"),*/
a!gridLayoutHeaderCell(label: "Percentage"),
a!gridLayoutHeaderCell(label: "Result"),
},
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: "DISTRIBUTE"),
a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
/*a!gridLayoutColumnConfig(width: "DISTRIBUTE"),*/
},
rows: {
a!forEach(
items: ri!studentData,
expression: a!gridRowLayout(
contents: {
a!integerField(
value: fv!item.RollNumber,
saveInto: fv!item.RollNumber,
disabled: true
),
a!textField(
value: fv!item.FullName,
saveinto: fv!item.FullName
),
a!integerField(
value: fv!item.Hindi,
saveInto: fv!item.Hindi,
validations: {
if(
fv!item.Hindi>100,
"Marks should be between 0 and 100",
if(
fv!item.Hindi< 0,
"Marks should be between 0 and 100",
"")
)
}
),
a!integerField(
value: fv!item.English,
saveInto: fv!item.English,
validations: {
if(
fv!item.English>100,
"Marks should be between 0 and 100",
if(
fv!item.English< 0,
"Marks should be between 0 and 100",
"")
)
}
),
a!integerField(
value: fv!item.Maths,
saveInto: fv!item.Maths,
validations: {
if(
fv!item.Maths>100,
"Marks should be between 0 and 100",
if(
fv!item.Maths< 0,
"Marks should be between 0 and 100",
"")
)
}
),
a!integerField(
value: fv!item.Physics,
saveInto: fv!item.Physics,validations: {
if(
fv!item.Physics>100,
"Marks should be between 0 and 100",
if(
fv!item.Physics< 0,
"Marks should be between 0 and 100",
"")
)
}
),
a!integerField(
value: fv!item.Chemistry,
saveInto: fv!item.Chemistry,
validations: {
if(
fv!item.Chemistry>100,
"Marks should be between 0 and 100",
if(
fv!item.Chemistry< 0,
"Marks should be between 0 and 100",
"")
)
}
),
a!integerField(
value: fv!item.Hindi+fv!item.English+fv!item.Maths+fv!item.Chemistry+fv!item.Physics,
saveInto:fv!item.MarksObtained,
disabled:true
),
/*a!integerField(*/
/*value: fv!item.TotalMarks,*/
/*saveInto: fv!item.TotalMarks*/
/*),*/
a!floatingPointField(
value: (fv!item.Hindi+fv!item.English+fv!item.Maths+fv!item.Chemistry+fv!item.Physics)/fv!item.TotalMarks*100 ,
saveInto: fv!item.Percentage,
disabled: true
),
a!textField(
value: If(
(fv!item.Hindi+fv!item.English+fv!item.Maths+fv!item.Chemistry+fv!item.Physics)/fv!item.TotalMarks*100 > 33,
"Pass",
"Fail"
),
saveinto: fv!item.Result,
disabled: true
),
}
)
)
},
selectionSaveInto: {},
addRowLink: a!dynamicLink(
label: "Add Student",
saveInto: {
}
),
validations: {},
shadeAlternateRows: true
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Submit",
saveInto: {
},
submit: true,
style: "PRIMARY"
)
},
secondaryButtons: {
a!buttonWidget(
label: "Cancel",
value: true,
saveInto: ri!cancel,
submit: true,
style: "NORMAL",
validate: false
)
}
)
)
)