Why would anyone want to do that you might ask? Surely a user will want to see something they are going to update? Well, imagine this scenario. You have a membership application and this system has a flag on the membership table for membership approval.
Membership status can either be ApprovedYN=”True” for “Approved” or ApprovedYN=”False” for “Awaiting Approval”.
Imagine then that you have hundreds of membership applications and that at some point you have to go and update their status to Approved when their subscription fee has cleared.
It would be nice if XMod Pro had an update button for templates. This may be on the cards for a future version or perhaps the <DeleteButton>
might be renamed to <UpdateButton>. But for now, there is nothing to stop you from using the <DeleteButton>
to carry out one-click updates.
The delete button can make a SQL call but it can also call a stored procedure. Therefore there is nothing to stop you from using the delete button mechanism to perform updates, inserts and of course, deletes.
For example, this <DeleteCommand>
updates the ApprovedYN flag on a table.
<DeleteCommand CommandText="UPDATE membership SET ApprovedYN = CASE
WHEN ApprovedYN = 'Yes' THEN 'No'
WHEN ApprovedYN = 'No' THEN 'Yes'
END where id=@memberID" >
<Parameter name="memberID" alias="memberID" />
</DeleteCommand>
If the delete link requires some kind of value based display you can do something like this:
<xmod:Select>
<Case CompareType="text" operator="=" value='[[approvedyn]]' expression="Yes" ignorecase="true">
<td>
<xmod:DeleteLink text="Approve" onclientclick="return confirm('make this person's membership unapproved?');">
<Parameter name="memberID" value='[[id]]' />
</xmod:DeleteLink>
</td>
</Case>
<Else>
<td>
<xmod:DeleteLink text="NOT Primary Approve" onclientclick="return confirm('approve this member?');">
<Parameter name="memberID" value='[[id]]' />
</xmod:DeleteLink>
</td>
</Else>
</xmod:Select>
Where the ApprovedYN field is checked with an <xmod:Select>
and the delete text is based on the existing value.
As you can see from this simple example, XMod Pro offers a very powerful and flexible way of firing off database commands with template buttons or links.
I hope you find it useful.
thanks for reading,
Gus