HI All,
I am using the below javaScript when there is a change in the data in a column. You can find i have highlighted a code in this Javascript which fetches the value from a column ( in Apex page) RATING. It was working fine but now from the column RATING which it is fetching a value it has some spaces in it and I cant find anything in regards to how to fetch a value which has spaces in it.... For Eg '2 '. It was working fine if it is like this '2'. what should i type to fetch a value which has spaces in it using JavaScript.
// First get the interactive table as a model
var model = apex.region("emp").widget().interactiveGrid("getViews", "grid").model;
// get the lead eprint ID the user typed in
var leadEprintId = $('#ID_LEP').val();
// and the equivelant EPRINTID
var eprintId = $('#ID_EP').val();
// now get the key for the EPRINTID
var epIdKey = model.getFieldKey("EPRINTID");
var eprintIdrating;
var updateCount = 0;
console.log("Looking for the rating for LEAD EPRINT ID " + leadEprintId + " with an EPRINTID of " + eprintId);
// Get the rating for LEAD EPRINTID that has just been added
model.forEach(function(r, index, id)
{
if (r[epIdKey] == leadEprintId)
{
console.log("FOUND EPRINTID " + leadEprintId);
eprintIdrating = model.getValue( r, "RATING"); ------ this one
}
});
alert(eprintIdrating);
//xxxx
if(typeof eprintIdrating !== "undefined" && eprintIdrating.d == '')
{
alert('Score Not available for this EPrintID');
}
model.forEach(function(r, index, id)
{
if (r[epIdKey] == eprintId && leadEprintId.length == 0)
{
// console.log("Updating RATING for EPRINTID " + r[epIdKey] + " Author " + model.getValue( r, "AUTHOR") + " to be now " + eprintIdrating.d);
model.setValue(r, "RATING", {d:'', v:''});
updateCount++
}
});
console.log("the rating for THE LEAD EPRINT ID IS " + eprintIdrating.d);
// Now update all ratings for every EPRINTID that matches the EPRINTID row that has just been updated
model.forEach(function(r, index, id)
{
if (r[epIdKey] == eprintId)
{
console.log("Updating RATING for EPRINTID " + r[epIdKey] + " Author " + model.getValue( r, "AUTHOR") + " to be now " + eprintIdrating.d);
model.setValue(r, "RATING", {d:eprintIdrating.d.trim(), v: eprintIdrating.v.trim()});
updateCount++
}
});
console.log("updateCount " + updateCount);
// The currently selected row RATING does not get updated in the loop above, this looks like a bug in APEX. The next section ensures that the
// current row also gets updated.
var grid = apex.region("emp").widget().interactiveGrid("getViews", "grid");
var m = grid.model;
var selectedRow = grid.view$.grid("getSelection") ;
selectedRow.forEach(function(o, index) {
var id = $(selectedRow[index][0]).data('id');
var record = m.getRecord(id);
m.setValue(record, "RATING", {d:eprintIdrating.d.trim(), v: eprintIdrating.v.trim()});
});
Any tips will be helpful
Thanks