Ad
How To Loop Rows (other Than Current Row) In Subgrid Using JS In Dynamics 365
I am able to read a Subgrid cell value triggered by OnChange using web resource.
Following which, I would need to loop through the remaining rows (except current row) in the subgrid and read each cell value for each row.
May I know how can it be done?
Current code snippet:
function SetNA(context) {
debugger;
//id of the subgrid
var id = formContext.data.entity.getId();
// get the attribute which fired the onchange.
var changedFirstNameAttr = context.getEventSource();
// get the container for the attribute.
var attrParent = changedFirstNameAttr.getParent();
// var FirstName Field Attribute
var changedFirstNameField = attrParent.attributes.get("firstName");
// get the value of the changed first name value
var changedFirstNameValue = changedFirstNameAttr.getValue();
alert(changedFirstNameValue);
if (changedFirstNameValue != null)
{
//loop through other rows in the subgrid, and read each cell value
}
}
Ad
Answer
You should be able to use getRows method to pull and iterate through all the editable grid rows and achieve what you want.
var gridRows = gridContext.getGrid().getRows();
//loop through each row to get values of each column
gridRows.forEach(function (row, i) {
var gridColumns = row.getData().getEntity().getAttributes();
//loop through each column in row
gridColumns.forEach(function (column, j) {
var atrName = column.getName();
var atrValue = column.getValue();
});
});
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad