Apr 29, 2021, 5:46 AM
[CLOSED] grid column rendered and grid comman event
Hello
I have generic question, just looking for direction for further investigate
we would like to have grid with couple of columns and first column would be a link ( i.e would look like hyperlink) and lastcolum "edit" button.
Now - on clicking edit I can easilly handle "command" event
I would like to handle same event on clicking a link
If link is rendered using renderer, is there a way that on click link I can handle command event?
I know that there is cellclick event, but how to distinguish whether first cell with hyperlink was clicked (or ideally hyperlink itself) or any other cell?
Idea demonstrate example below ( so on clicking link in first cell I would like to get executed onCommand event)
Note that ideally if I can do this easilly for all the grids in the app that has edit command in last column and hyperlink in first
Thanks
I have generic question, just looking for direction for further investigate
we would like to have grid with couple of columns and first column would be a link ( i.e would look like hyperlink) and lastcolum "edit" button.
Now - on clicking edit I can easilly handle "command" event
I would like to handle same event on clicking a link
If link is rendered using renderer, is there a way that on click link I can handle command event?
I know that there is cellclick event, but how to distinguish whether first cell with hyperlink was clicked (or ideally hyperlink itself) or any other cell?
Idea demonstrate example below ( so on clicking link in first cell I would like to get executed onCommand event)
Note that ideally if I can do this easilly for all the grids in the app that has edit command in last column and hyperlink in first
Thanks
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object[]
{
new object[] { "3m Co", 71.72, 0.02, 0.03},
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47},
new object[] { "Altria Group Inc", 83.81, 0.28, 0.34},
new object[] { "American Express Company", 52.55, 0.01, 0.02},
new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49},
new object[] { "AT&T Inc.", 31.61, -0.48, -1.54},
new object[] { "Boeing Co.", 75.43, 0.53, 0.71},
new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39},
new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04},
new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28}
};
this.Store1.DataBind();
}
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<script>
var template = '<span style="color:{0};">{1}</span>';
function renderer(value) {
return '<a href=\'#\'>' + value + '</a>';
}
var onCommand = function (column, command, record, recordIndex, cellIndex) {
Ext.Msg.alert('Command', 'Command = ' + command + '<br/>' + 'company = ' + record.get('company'));
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Cell commands"
Width="700"
Height="300">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
<ext:ModelField Name="price" Type="Float" />
<ext:ModelField Name="change" Type="Float" />
<ext:ModelField Name="pctChange" Type="Float" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1">
<Renderer Fn="renderer"></Renderer>
</ext:Column>
<ext:Column runat="server" Text="Price" Width="100" DataIndex="price" Align="End" />
<ext:CommandColumn Width="70">
<commands>
<ext:GridCommand Icon="Lock" CommandName="Edit" Text="<%$ Res:Edit %>">
<ToolTip Text="Edit" />
</ext:GridCommand>
</commands>
<Listeners>
<Command Fn="onCommand"/>
</Listeners>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Multi" />
</SelectionModel>
</ext:GridPanel>
</form>
</body>
</html>
Last edited by fabricio.murta; May 10, 2021 at 11:21 PM.