I have a grid that builds from Sharepoint list... the problem I have is that in my list (data table) I have a value that is recorded as an array, I know I can format the result on the grid using a template, however when I do this I can use the sort function. I think that it's because when the grid builds it sees that the results are [Object object] and not the final result.
My code is something like this
var currentContext = new SP.ClientContext.get_current();
var targetList = currentContext.get_web().get_lists().getByTitle('Flujos');
var camlBuilder = new CamlBuilder();
var query = camlBuilder.Where().TextField("Activa").EqualTo("true").ToCamlQuery();
ListItems = targetList.getItems(query);
currentContext.load(ListItems);
currentContext.executeQueryAsync(Succeeded, Failed);
function Succeeded() {
var listEnumerator = ListItems.getEnumerator();
var solEntries = [];
while (listEnumerator.moveNext()) {
var item = listEnumerator.get_current();
var entry = item.get_fieldValues();
solEntries.push(entry);
}
$("#grid").kendoGrid({
culture: "es-CL",
toolbar: ["excel"],
excel: {
fileName: "GerenciaPersonas_" + fec1 + ".xlsx",
filterable: true
},
dataSource: solEntries,
/*pageable: {
scrollable: true,
refresh: true,
pageSizes: true,
buttonCount: 5
},*/
scrolling: true,
sorting: {
multiple: true
},
height: "500px",
sortable: {
mode: "single",
allowUnsort: false
},
paging: false,
filterable: {
mode: "row",
},
selection: {
type: "row",
multiple: true,
toggle: false
},
columns: [
{ field: "Solicitud", title: "Solicitud", template: "#= formatSolicitud(data) #", width: "90px", filterable: false },
{ field: 'Created', title: 'Creada', width: "70px", filterable: false, format: "{0:dd-MM-yyyy}" },
{ field: 'Activa', title: 'Activa', width: "50px", filterable: false }
]
});
var grid = $("#grid").data("kendoGrid");
} // FIN SUCCEED
After this the results are like this : Image of the Result
I know I can use a template with this function
function formatSolicitud(o) {
var firstFieldName = Object.keys(JSON.parse(JSON.stringify(o.Solicitud)))[1];
var object = JSON.parse(JSON.stringify(o.Solicitud));
var res = object[firstFieldName];
return res;
}
How ever I can't use the sort function, it just doesn't sort at all, and I think that it's because the grid saw that the results where [Object object] before being transformed.
I would love some help on this topic.