Welcome Guest Search | Active Topics | Sign In | Register

Putting Two ButtonCoulumns (hyoerlinks) into a single grid column Options
Markpoid
Posted: Monday, February 21, 2011 1:36:39 PM
Rank: Newbie
Groups: Member

Joined: 10/27/2010
Posts: 5
I am looking to have a single column with two hyperlinks (or two ButtunColumns) in a single column. Each hyperlink functions needs to fire the ItemCommand event on the server like ButtonColumnn does. I assume that this can be done with a custom column but I am not sure the best way to do this.
eo_support
Posted: Monday, February 21, 2011 2:23:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can use a StaticColumn for that case. Follow these steps:

1. Make sure you have a unique key field in your data source. This field, instead of item index will be used to identify which row has been clicked;

2. Set the StaticColumn's DataField to the name of your key field. For example, if the name of the key field is "rec_id", then you can set DataField to "rec_id";

3. Set the StaticColumn's DataFormat to something like this:

Code: HTML/ASPX
<a href="raisesGridEvent('cmd1', {0})">Command 1</a> 
<a href="raisesGridEvent('cmd2', {0})">Command 1</a>


The above code will display two HTML links inside the Grid cell. The Grid will replace {0} with your data field value. So for example, for a row with "rec_id" as 10, the Grid will display two links in the cell and call:

Code: JavaScript
raisesGridEvent('cmd1', 10);


When the first link is clicked, And

Code: JavaScript
raisesGridEvent('cmd2', 10);


when the second link is clicked.

4. You will need to implement raisesGridEvent to perform whatever action you need based the arguments passed in. Note this part no longer has anything to do with the Grid. For example, you can implement the function like this:

Code: JavaScript
function raisesGridEvent(cmd, rec_id)
{
    alert("performing " + cmd + " on record " + rec_id);
}


If you need it to raise a server event, you can place a ScriptEvent control in the form and then call global function eo_TriggerServerEvent to trigger the ScriptEvent's server side Command event and then handle that event (make sure you pass your "cmd" and "rec_id" in). Note this event is not related to Grid's ItemCommand event in any way. You can find more information on how to use eo_TriggerServerEvent here:

http://doc.essentialobjects.com/library/1/eo.web.scriptevent.aspx

Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!

Markpoid
Posted: Monday, February 21, 2011 2:52:27 PM
Rank: Newbie
Groups: Member

Joined: 10/27/2010
Posts: 5
It worked perfectly. Thanks.
eo_support
Posted: Monday, February 21, 2011 3:10:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Great. Glad that it works for you!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.