Sep 20, 2011, 2:49 PM
[CLOSED] How to Display Confirmation Message From an ImageCommand Column Dynamically
I have a grid which has a column that dynamically displays an image command for "Approve" OR "Unapprove".
Only when the command is "Unapprove", do I need to display a confirmation message and, when confirmed by the user, I will perform an action defined in the direct event.
Sample code below:
Only when the command is "Unapprove", do I need to display a confirmation message and, when confirmed by the user, I will perform an action defined in the direct event.
Sample code below:
<%@ Page Language="vb" AutoEventWireup="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not ExtNet.IsAjaxRequest Then
Dim data As New List(Of Object)
With data
.Add(New With {
.reportid = 1,
.desc = "1st Quarter Returns",
.source = "Wizard",
.status = "Pending Approval",
.statusid = 3,
.lastmodified = "1/1/2010",
.uploadedby = "Indiana Jones"})
.Add(New With {
.reportid = 2,
.desc = "2nd Quarter Returns",
.source = "Upload",
.status = "Approved",
.statusid = 4,
.lastmodified = "12/31/2010",
.uploadedby = "Hans Solo"})
End With
ReportsStore.DataSource = data
ReportsStore.DataBind()
End If
End Sub
Protected Sub ReportGrid_Command(ByVal sender As Object, ByVal e As DirectEventArgs)
Dim reportid = CInt(e.ExtraParams("key"))
Select Case e.ExtraParams("command")
Case "approve"
'approve the report
Case "unapprove"
'unapprove the report
End Select
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
.actionLink
{
color: #0033ff;
}
.actionLink:hover
{
color: #0033ff;
text-decoration: underline;
}
</style>
<script type="text/javascript">
var prepareReportGridCommands = function (grid, commands, record, row, col, value) {
var s = record.get('statusid');
if (s == 3 || s == 15) {
commands.push({
command: 'approve',
iconCls: 'actionLink',
text: 'Approve'
});
}
if (s == 4 || s == 16) {
commands.push({
command: 'unapprove',
iconCls: 'actionLink',
text: 'Unapprove'
});
}
};
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<div>
<ext:GridPanel ID="GridPanel1" runat="server" AutoExpandColumn="desc" Border="false">
<Store>
<ext:Store ID="ReportsStore" runat="server">
<Reader>
<ext:JsonReader IDProperty="reportid">
<Fields>
<ext:RecordField Name="reportid" Type="Int" />
<ext:RecordField Name="desc" Type="String" />
<ext:RecordField Name="source" Type="String" />
<ext:RecordField Name="status" Type="String" />
<ext:RecordField Name="statusid" Type="Int" />
<ext:RecordField Name="lastmodified" Type="date" />
<ext:RecordField Name="uploadedby" Type="String" />
</Fields>
</ext:JsonReader>
</Reader>
<SortInfo Field="desc" Direction="DESC" />
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ColumnID="Description" Header="Description" DataIndex="desc" Width="300" />
<ext:Column ColumnID="Source" Header="Source" DataIndex="source" />
<ext:Column ColumnID="Status" Header="Status" DataIndex="status" Width="205">
<PrepareCommands Fn="prepareReportGridCommands" />
<Commands>
<ext:ImageCommand Icon="MoneyDollar" CommandName="dummy" Hidden="true" />
</Commands>
</ext:Column>
<ext:DateColumn Align="Center" ColumnID="LastModified" Header="Last Modified" DataIndex="lastmodified" />
<ext:Column ColumnID="UploadedBy" Header="Uploaded By" DataIndex="uploadedby" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
</SelectionModel>
<BottomBar>
<ext:PagingToolbar ID="Pager" runat="server" PageSize="10" HideRefresh="true" />
</BottomBar>
<DirectEvents>
<Command OnEvent="ReportGrid_Command">
<ExtraParams>
<ext:Parameter Name="command" Value="command" Mode="Raw" />
<ext:Parameter Name="key" Value="record.id" Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:GridPanel>
</div>
</form>
</body>
</html>
Last edited by Daniil; Sep 20, 2011 at 6:06 PM.
Reason: [CLOSED]