Get RowID in editor when displaying file link
Get RowID in editor when displaying file link
joshlevine102
Posts: 44Questions: 16Answers: 2
in Editor
Hi folks. I was looking at displaying a link or image for an uploaded file, like in the example code given.
display: function ( id ) {
return '<img src="'+editor.file( 'images', id ).webPath+'"/>';
},
Dumb question, is there a way to get the Row_ID or primary key of the row that's being edited at that point in the editor? I guess this would only make sense if only one row was selected, or otherwise it might be a collection. But I was thinking I might be able to do something like this, but I can't figure it out.
editor.field("bis401_sites.Site_ID")
// or
editor.field("DT_RowID") // or editor.field("id"), or something...
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Currently you cannot I'm afraid. The reason for this is that if you upload a file in a "create" form there is no primary key value (since the database hasn't created one yet - assuming you have an auto-inc pkey).
Allan
Allan, thanks. OK. I was thinking, if I could get the pkId of the row in the sites table (which has a foreign key into the files table), I could add a delete link which would just set that file id column to be null, as a way of deleting the file, assuming the DbClean might then delete the corresponding file row, since it was now unreferenced. But there may be an easier way to delete files.
I guess it makes more sense to just delete the file row, and it should update the foreign key column in the sites table, if the delete action is set properly in the DB.
The
update
field type has aclearText
option which when set will enable a "clear" button which basically will set the database link to null. That way the DbClean can indeed pick it up.Regards,
Allan
Allan, thanks. The clearText option was just what I was looking for. Worked perfectly!