PDA

View Full Version : [CLOSED] Gridcommand listener and Rowselection directevent



alessandra.monica
Jul 12, 2013, 12:40 PM
Hi,

is there a way to call a javascript function on a GridCommand or ImageCommand inside a Grid
without calling the directevent associated to the rowselection as well?

I mean. I have this Grid:



<ext:GridPanel runat="server" ID="templategrid" AutoScroll="true" StoreID="TemplateStore" Height="400">
<ColumnModel>
<Columns>

<ext:CommandColumn ID="colEditTemplate" Width="25" runat="server" OverOnly="True">
<Commands>
<ext:GridCommand Icon="Pencil" CommandName="cmdEditTemplate">
<ToolTip Text="<%$ I18n: EditText %>" />
</ext:GridCommand>
</Commands>
<Listeners>
<Command Handler="return testfunction(record, command); return false;"></Command>

</Listeners>
</ext:CommandColumn>

<%--Fields for List Mode--%>
<ext:Column ID="colId" runat="server" DataIndex="Id" Hidden="True" />
<ext:Column ID="colDescription" runat="server" DataIndex="Description" Header="<%$ I18n: Label_Description %>" Width="400" Groupable="true" Sortable="true" MenuDisabled="False" />
</Columns>
</ColumnModel>
<%--Selection Model--%>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single">
<DirectEvents>
<Select OnEvent="GetTemplateBlocks">
<EventMask ShowMask="true" />
<ExtraParams>
<ext:Parameter Name="TemplateId" Value="record.data.Id" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>



When I click the gridcommand icon, the testfunction in javascript is called but is called also the code behind directevents GettemplateBlocks
of the row selection.
Is there a way to avoid this? I would like that when I click the GridCommand only the javascript testfunction is executed.

Thanks

Daniil
Jul 12, 2013, 3:34 PM
Hi @alessandra.monica,

Please demonstrate the "testfunction" definition. Do you not select a row inside it?

The Select event doesn't fire if click a GridCommand in this test case.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "test1", "test2", "test3" },
new object[] { "test4", "test5", "test6" },
new object[] { "test7", "test8", "test9" }
};
}
}

protected void OnSelect(object sender, DirectEventArgs e)
{
X.Msg.Alert("OnSelect", "Hello from Server!").Show();
}
</script>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test1" DataIndex="test1" />
<ext:Column runat="server" Text="Test2" DataIndex="test2" />
<ext:Column runat="server" Text="Test3" DataIndex="test3" />
<ext:CommandColumn ID="colEditTemplate" Width="25" runat="server" OverOnly="True">
<Commands>
<ext:GridCommand Icon="Pencil" CommandName="cmdEditTemplate">
</ext:GridCommand>
</Commands>
<Listeners>
<Command Handler="console.log('Command');"></Command>
</Listeners>
</ext:CommandColumn>

</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Single">
<DirectEvents>
<Select OnEvent="OnSelect" />
</DirectEvents>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
</form>
</body>
</html>

alessandra.monica
Jul 16, 2013, 11:50 AM
Hi Daniil,
sorry for the late.

tesfunction contains simply an alert javascript, nothing more, just for example.

In any case I have tried your example but here every time I click the pencil, the OnSelect
function server-side is called (so the row is "selected")

Which version are you using to test?

Thanks

Daniil
Jul 16, 2013, 3:07 PM
I was able to reproduce it with the v2.2 release.

However, it is not reproducible with the trunk. Could you update from the SVN trunk?

alessandra.monica
Jul 17, 2013, 8:07 AM
Hi Daniil,

I have updated with the trunk and indeed it works, OnSelect is not called anymore.

Do you know when the Ext.Net version 2.3 will be available for download?

Thanks

Daniil
Jul 17, 2013, 2:42 PM
The official v2.3 release should happen very soon. Maybe, even this week. The next week should be for sure.

Do you not want to use the trunk?

alessandra.monica
Jul 17, 2013, 2:55 PM
The official v2.3 release should happen very soon. Maybe, even this week. The next week should be for sure.

Do you not want to use the trunk?

We prefer to use the official released version :-)))
We will wait for it, no problem!

Thank you very much.

You can close the thread!