Hi,
I'm trying to display some json data in the grid (2017.1). I've set the grid up as follows:
$("#jobs").igGrid({ dataSource: gdata, width: "100%", renderCheckboxes: true, autoGenerateColumns: false, columns: [ { key: "Haulier", headerText: "Company", dataType: "string" }, { key: "Job", headerText: "Job", dataType: "string", unbound: true, template: jobTemplate }, { key: "JobType", headerText: "Job Type", dataType: "string" }, { key: "CollectionFrom", headerText: "Collection", dataType: "string" }, { key: "DeliveryTo", headerText: "Delivery", dataType: "string" }, { key: "DateAssigned", headerText: "Assigned to you", dataType: "date", format: "yyyy-MM-dd HH:mm" }, { key: "AssignedTo", headerText: "Driver", dataType: "string" } ], features: [ { name: "Filtering" }, { name: "Paging", showPageSizeDropDown: false }, { name: "Sorting" }, { name: "Selection", inherit: true } ] });
jobTemplate is defined as < a href=/SupplierPortal/Itinerary/Itinerary/${ItineraryID}>${Reference}< /a> (spaces added to avoid being interpreted as HTML)
So I want a link that ends in the value of the ItineraryID fields from the json, and displays the Reference field on the page. The column on the grid remains blank though (the other columns are populated okay). I presume I'm not specifying the column template correctly - can anyone tell me what it should be?
The json looks like this (but with more rows):
[{"ItineraryID":"b7a46736-4a06-4cf5-94e7-5a2b67c1ad3e","Haulier":"Test","Reference":"RX356562","JobType":"Collection","CollectionFrom":"JGRG233396/1: Bousbecque 59166","DeliveryTo":"","DateAssigned":"2016-10-07T13:11:00","AssignedTo":null}]
I've followed it through a bit further, and it looks like something not working the way it should. If I replace the template contents with this, then it "works":
< a href=/SupplierPortal/Itinerary/Itinerary/${ItineraryID}>Test< /a>
So if the link text is a static value then it is displayed correctly (though the result is not very useful!)
I wondered if it didn't like referencing multiple fields in the template, so tried the following:
< a href=/SupplierPortal/Itinerary/Itinerary/${ItineraryID}>${ItineraryID}< /a>
This reverted to leaving the cell blank again.
Should what I'm try to do work? I want the link address and the display text to be determined by the underlying data. I'm hoping it's something I can resolve quickly, as this would be a show stopper for us :-(
Kevin
Actually, the static text example doesn't work either - the text might display okay, but the URL comes out as http://localhost:38858/SupplierPortal/Itinerary/Itinerary/ - the route part is missing. It looks like none of the field references are working anywhere in the template?!? I'm hoping now that this is something really stupid I'm doing - any thoughts?
I've reproduced the problem in a static HTML page. I've zipped this up, along with the infragistics CSS/JS files I'm using and attached it. Can someone take a look and tell me what I'm doing wrong?
This is what I see when I open that file in Chrome. Problem is still there in IE and Edge
(also here https://www.dropbox.com/s/tf7mtat21ro7afs/capture.png?dl=0 in case the image doesn't display):
The templating engine seems to be working okay - if I add the following:
var rend = $.ig.tmpl('${ItineraryID}', gdata)
I can see the correct value is pulled from the data. Just doesn't seem to work as a column template :-(
Hello Kevin,
Thank you for posting to our forum.
I would like to update you that i am working on your case , going through all the updates you provided
and would update you by tomorrow EOD.
Thank you for the update.
I would defiantly recheck that information in our online document or ask our documentation team to modify our documents.
Thanks Divya,
I'd suggest it would be worth adding a note to the "Creating a basic column template" documentation page to indicate that a field must also be present as a column if you are planning to include it in a template. I don't think this is particularly obvious - one would assume the template engine refers to the data source rather than the column list
Thank you for providing a sample.
I looked into the code and noticed that to have a link you are using this code :
< a href=/SupplierPortal/Itinerary/Itinerary/${ItineraryID}>${Reference}< /a>
But you did not added ‘ItineraryID’ and ‘Reference’ columns in the grid.
I have added these columns in the grid column collection, made them hide in the grid and have string in a single quote, made code working as expected with the column template.
Please refer the attached modified code for your reference and let me know if you need further assistance on this matter.
Thank you Divya. For the moment I have worked around it by passing the preformed anchor tag through in the model data, so no formatting is required in the grid. It would be great to have the option to do it via the column template as well though