Dear Isomorphic,
The day is drawing to a close (or has closed alreday to be honoust). Almost done with my php WSDL server. Just the remove operations to implement.
Therefore the following question: I would like to add a delete button to each row. I tried the following (and a lot of things like it), but I cannot seem to get it right. Assistance would be appreciated.
fields: [ { name: "_delete", title: "remove", canEdit: false, canSort:false, canGroupBy:false, canFilter:false, width:30, type: "image", imgURLPrefix: "[SKINIMG]/actions/", imgURLPostfix: ".png", displayField:"remove" } ]
Best Regards,
Arjan Mels
Are you on 7.0 beta? See the docs for ListGridFieldType, specifically type:“icon”.
Switching between version 6.5.1 and 7 beta (as I still am encountering issues here and there)
This “icon” type seems to be new to version 7 (great!). Is there also a solution that will work on 6.5.1?
Best Regards,
Arjan Mels
Yes, relative to your current code, you’d primarily just need to remove ‘displayField:“remove”’ and add a cellClick() handler.
Dear Isomorphic,
The cell click is ok. Howver just removing the displayField does not give me the desired result. I think the listgrid tries to retrieve its value (should be the image url?) form the datasource, but this field is clearly not present in teh datasource.
In the mean time I found a way, but it is a bit clumsy:
fields: [
{
name:"_delete", title: "X",
showHover: false, canEdit: false, canSort:false, canGroupBy:false, canFilter:false,
width:20, type: "image", getRawCellValue: function(viewer,record,recordNum,field,fieldNum,value)
{
return "[SKINIMG]/actions/remove.png"
},
recordDoubleClick: function(viewer, record, recordNum, field, fieldNum, value, rawValue)
{
searchResults.removeSelectedData();
// viewer.removeData(record);
}
} ]
A more elegant solution than overriding the getRawCellValue would be nice…
Best Regards,
Arjan
Careful with source browsing, that’s an internal API you’re using. Best to start from the docs: formatCellValue can do something similar, just return isc.Canvas.imgHTML().
Dear Isomorphic,
Thank you for the advice, will look into it.
Best Regards,
Arjan Mels