TWebDBResponsiveGrid ItemTemplate


How do I add a button to the template with an onclick event. Preferably this should use a material glyph.



Did you check:

Ah, thanks.

The onclick event is never fired using it the code below. Instead the underlying item is focused.

  gArtwork.Options.ItemTemplate:='<div style="width:300px;height:200px;" class="text-center">'+
    '<img draggable="false" ondragstart="return false;" style="width:auto;max-width:300px;'+
    'height:200px;padding:10px 0px 2px 6px;" src="data:image/jpg;base64,(%Img%)">'+
    '<span style="float:right"><button id="btnEdit">Edit</button></span>'+
    '<div style="margin:0px 12px 0px 12px">(%Title%)'+
    '<span style="float:right">(%ImgOrder%)</span>'+

Is one such button created? Multiple buttons?
If multiple, this can't work as you map different buttons on the same id. Id's should be unique as shown in the blog article.

I only have one template and one button created but this is a DB Responsive grid which can have any number of records.

I have no idea as I do not have the complete scope of your project.
I suggest to compare with the project demonstrated in the blog article.

This does work:

<span style="float:right"><button onclick="pas.MainFrm.MainForm.btnEditClick()">Edit</button></span>

And even better:

<span class="material-icons" style="float:right;font-size:36px;color:black;" onclick="pas.MainFrm.MainForm.btnEditClick()">edit</span>

1 Like