Hi everyone,
I am stucked in a very bad condition the problem is with the table rows and columns. I am generating dynamic table columns and rows based on searched unit so whenever i am searching i created a function for initializing the table rows and columns i am looping the array for whatever the size of rows and columns it will display up to 5. My issue is with the request going is adding more times then the required one. So if anyone can check for the solution. Only problem is my data is generated correct but next time i call this method again it is hiding the first 2 rows.
function initializeGrid() {
if (SHOPFLOOR_DCS_UNIT_KEY != null) {
var dcsComboBox = sap.ui.getCore().byId("selectDCSName");
var dcsName = dcsComboBox.getValue();
var viewData = {};
viewData.EntityName = "DataCollectionSetAttribute";
viewData.Condition = [{ColumnName : "DcsName",Value :dcsName}];
viewData.Projection = {AttributeName:true,AttributeType:true,Length:true,Precision:true,LowerLimit:true,
UpperLimit:true,DefaultValue:true };
$
.ajax({
type : "POST",
url : "/demo/xsds/designer/SelectByQueryService.xsjs",
contentType : "application/json",
data : JSON.stringify(viewData),
dataType : "json",
success : function(data) {
/*dcDataTable.unbindItems();
dcDataTable.removeAllItems();
dcDataTable.removeAllColumns();*/
var dcsCols = data;
if (data != null
&& data.length > 0) {
var firstColumn = [{
"AttributeName": "SerialNumber",
"ModifiedAttributeName": "SerialNumber"
}];
for (var index = 0; dcsCols.length > index; index++) {
var currentRow = dcsCols[index];
if (currentRow.AttributeName != null
&& currentRow.LowerLimit != null
&& currentRow.UpperLimit != null) {
dcsCols[index].ModifiedAttributeName = currentRow.AttributeName
+ "["
+ currentRow.LowerLimit
+ " - "
+ currentRow.UpperLimit
+ ","
+ "Def:"
+ currentRow.DefaultValue
+ "]";
firstColumn
.push(dcsCols[index]);
} else if (currentRow.AttributeName != null) {
dcsCols[index].ModifiedAttributeName = currentRow.AttributeName
+ "["
+ "Def:"
+ currentRow.DefaultValue
+ "]";
firstColumn
.push(dcsCols[index]);
}
if (currentRow.AttributeType != null
&& currentRow.AttributeType == "LocalDate")
{
dateAttributes[dateAttributes.length] = currentRow.AttributeName;
}
}
dcsCols = firstColumn;
runtimeDCS = dcsCols;
console.log("dcsCols", dcsCols);
var viewData = {};
viewData.EntityName = dcsName;
viewData.Cmd="GET";
viewData.UnitKey=SHOPFLOOR_DCS_UNIT_KEY;
$.ajax({
type : "POST",
url : "/demo/xsds/designer/AddOrRemoveDCSDataService.xsjs",
contentType : "application/json",
data : JSON.stringify(viewData),
dataType : "json",
success : function(data) {
console.log("dcsVals"+
JSON.stringify(data)+data.length);
dcDataTable.removeAllColumns();
for (var i = 0; i < data.length; i++) {
for (key in data[i]) {
var textValue = data[i][key];
if (typeof textValue !== "object"
&& typeof textValue === "string"
&& textValue
.indexOf("/Date(") > -1) {
var startIndex = textValue
.indexOf("(");
var endIndex = textValue.indexOf(")");
var tempValue = textValue.substring(startIndex + 1,endIndex);
var tempDate = new Date(parseInt(tempValue));
data[i][key] = tempDate.toDateString();
}
}
}
dcsModel.setData({dcsRows : data});
sap.ui.getCore().setModel(dcsModel);
var columnList = new sap.m.ColumnListItem();
dcDataTable.bindItems({
path: "/dcsRows/",
template: columnList,
});
for (var i = 0; i < dcsCols.length && i<5; i++) {
dcDataTable.addColumn(new sap.m.Column({
header : new sap.m.Label({
text : dcsCols[i].ModifiedAttributeName
})
}));
columnList.addCell(new sap.m.Text({
text : {
path : dcsCols[i].AttributeName
}
}));
}
clearItems();
},error : function(response) {
console.log("Request Failed==>",response);
if (response.responseText.indexOf('<html>') == -1)
console.log(JSON.stringify(response.responseText));
else
console.log("Invalid Service Name");
},
});
}
},error : function(response) {
console.log("Request Failed==>",response);
if (response.responseText.indexOf('<html>') == -1)
console.log(JSON.stringify(response.responseText));
else
console.log("Invalid Service Name");
}
});
}
else {
console.log("Data not found!!!");
}
}