I have utilized Angular ui-grid to display an array of json objects received in the response. However, my current scenario involves getting an array of string values instead. How should I configure the grid for this situation?
$http.get(url)
.success(function(data) {
if(data.length <= 0 && data != undefined) {
$scope.noDataGridEpr="Data is not Available";
console.log("Data is not Available");
}
console.log("Data is" + data);
$scope.prList = data;
console.log("prList is" + $scope.prList); //an array of strings
$scope.dataLoadedEpr=true;
return true;
})
.error(function(data, status) {
console.log("Error from controller. Could not query.");
return false;
})
This displays
prList is[A/DN,B/LCK,10,10,same,match,match],
[B/DN,D/LCK,10,10,same,mismatch,match],
[G/DN,D/LCK,10,10,same,mismatch,mismatch]
Below is my current grid setup
$scope.prGrid = {
data: 'prList',
columnDefs: [
{field: 'DPin', displayName: 'DPin', width: "5%"},
{field: 'CPin', displayName: 'CPin', width: "5%"},
{field: 'slack1', displayName: 'slack1', width: "5%"},
{field: 'slack2', displayName: 'slack2', width: "5%"},
{field: 'cComp', displayName: 'cComp', width: "10%"},
{field: 'dComp', displayName: 'dComp', width: "5%"},
{field: 'gComp', displayName: 'dComp', width: "5%"}
enableFiltering: true,
multiSelect: false,
enableGridMenu: true,
enableRowHeaderSelection: false,
enableSorting: true,
enableColumnResizing: true
};
I acknowledge that the field configuration above is incorrect. Since I am dealing with an array of strings as input, can someone provide guidance on how to assign each string in the array to a row in the grid?
Thank you.