PDA

View Full Version : [CLOSED] Store attribute "isUpload" from 1.x to 2.x



sisa
Mar 08, 2013, 12:57 PM
Hello everybody,

I'm currently upgrading a project from ext.net 1.x to the latest 2.x release.
The project contains two grids, a selection on the first grid causes the execution of a direct event which proccesses some logic and loads the store of the second grid. This second grid allows the user to download a file by clicking on a command button. To make this work, in the 1.x release we had to add the "isUpload" attribute to the store of the second grid. This attribute doesn't exist anymore as a store attribute, but judging from the ext.net 2.x examples this attribute has to be set from JS. However we don't have a JS but the store is filled directly from the code behind.
If we don't add this attribute ext.net loops forever and blocks the further execution of the page.

Below you can find a simplified example of our code.
If you need more details I'll be happy to supply them to you.



<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SafeViewExport.aspx.vb" Inherits="SISA.Safe.View.SafeViewExport" %>

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

<script type="text/javascript">
function dataCollectionSelected(mrn, version) {
showLoadingMask();

App.direct.GetDataCollectionByMRN(mrn, version,
{
success: function () {
hideLoadingMask();
}
});
}

var prepareDelete = function (grid, toolbar, rowIndex, record) {
if (record.get("DocumentType") != "other") {
var firstButton = toolbar.items.get(0);
firstButton.hide();
}
};

var prepareDownload = function (grid, toolbar, rowIndex, record) {
if (record.get("HasDocumentContent") == false) {
var firstButton = toolbar.items.get(0);
firstButton.hide();
}
};
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="SafeManager" runat="server" />

<sisa:RemotePagingStore ID="DataCollectionStore" runat="server" PagingToolbarID="DataCollectionPagingToolbar" AutoLoad="false">
<Model>
<ext:Model runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="MRN" />
<ext:ModelField Name="Version" />
<ext:ModelField Name="MRNComposed" />
<ext:ModelField Name="TraderDeclarationNumber" />
<ext:ModelField Name="TraderReference" />
<ext:ModelField Name="DocumentDateConverted" />
<ext:ModelField Name="AcceptanceDateConverted" />
</Fields>
</ext:Model>
</Model>
<Sorters>
<ext:DataSorter Property="MRN" Direction="ASC" />
</Sorters>
</sisa:RemotePagingStore>

<ext:Store ID="DocumentsStore" runat="server" SerializationMode="Simple">
<%--<DirectEventConfig IsUpload="true" />--%>
<Model>
<ext:Model runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="OriginalName" />
<ext:ModelField Name="HasDocumentContent" />
<ext:ModelField Name="DocumentName" />
<ext:ModelField Name="DocumentType" />
<ext:ModelField Name="ContentType" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Viewport ID="DataSourceViewport" runat="server" Layout="BorderLayout">
<items>
<ext:Container ID="CenterContainer" runat="server" Region="Center" Layout="BorderLayout" Margins="0 5 0 0">
<Items>
<ext:GridPanel ID="DataCollectionGridPanel" runat="server" StripeRows="true" StoreID="DataCollectionStore" TrackMouseOver="True"
Region="Center" Margins="5 0 0 0">
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" ColumnID="Id" Header="Id" Hidden="true" DataIndex="Id" />
<ext:Column runat="server" Header='<%$ I18n: Label_CustomsReferenceMRN %>' Width="120" DataIndex="MRN" Hidden="true" />
<ext:NumberColumn runat="server" Header='<%$ I18n: Label_Version %>' Width="120" DataIndex="Version" Hidden="true" />
<ext:Column runat="server" Header='<%$ I18n: Label_MRNVersion %>' Width="200" DataIndex="MRNComposed" />
<ext:Column runat="server" Header='<%$ I18n: Label_TraderDeclarationNumber %>' Width="120" DataIndex="TraderDeclarationNumber" />
<ext:Column runat="server" Header='<%$ I18n: Label_TraderReference %>' Width="120" DataIndex="TraderReference" />
<ext:Column runat="server" Header='<%$ I18n: Label_DocumentDate %>' Width="120" DataIndex="DocumentDateConverted" />
<ext:Column runat="server" Header='<%$ I18n: Label_AcceptanceDate %>' Width="120" DataIndex="AcceptanceDateConverted" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="DataCollectionRowSelectionModel" runat="server" SingleSelect="true">
<Listeners>
<Select Handler="dataCollectionSelected(#{DataCollectionGridPanel}. getSelectionModel().getSelection()[0].get('MRN'), #{DataCollectionGridPanel}.getSelectionModel().get Selection()[0].get('Version'));" />
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>
<BottomBar>
<ext:PagingToolbar ID="DataCollectionPagingToolbar" runat="server" PageSize="10">
<Items>
<ext:ToolbarSeparator runat="server" />
<ext:Label ID="DataCollectionPageSizeLbl" runat="server" Text='<%$ I18n: Label_PageSize %>' />
<ext:ToolbarSpacer runat="server" Width="10" />
<ext:ComboBox ID="ComboBox" runat="server" Width="80">
<Items>
<ext:ListItem Text="10" />
<ext:ListItem Text="20" />
<ext:ListItem Text="50" />
</Items>
<SelectedItems>
<ext:ListItem Value="10" />
</SelectedItems>
<Listeners>
<Select Handler="#{DataCollectionStore}.pageSize = parseInt(this.getValue()); #{DataCollectionStore}.load();" />
<%--<Select Handler="#{DataCollectionPagingToolbar}.pageSize = parseInt(this.getValue()); #{DataCollectionPagingToolbar}.doLoad();" />--%>
</Listeners>
</ext:ComboBox>
</Items>
</ext:PagingToolbar>
</BottomBar>
</ext:GridPanel>
</Items>
</ext:Container>

<ext:Container runat="server" Width="400" Region="East" Layout="VBoxLayout">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:GridPanel ID="DocumentsGridPanel" runat="server" Title='<%$ I18n: Caption_Documents %>' StripeRows="true" StoreID="DocumentsStore" TrackMouseOver="True" Flex="2">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="OpenWindowBtn" Icon="PageWhiteGet" runat="server" Disabled="true" ToolTip='<%$ I18n: Tooltip_UploadDocument %>'>
<Listeners>
<Click Handler="showComponent('UploadDocumentWindow');" />
</Listeners>
</ext:Button>
<ext:Button ID="SendDocumentsButton" Icon="EmailGo" runat="server" Disabled="true" ToolTip='<%$ I18n: Tooltip_SendDocumentsByEMail %>'>
<Listeners>
<Click Handler="showComponent('SendDocumentWindow');" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel runat="server">
<Columns>
<ext:CommandColumn runat="server" Width="30">
<Commands>
<ext:GridCommand Icon="PageWhitePut" CommandName="Document" >
<ToolTip Text='<%$ I18n: Tooltip_DownloadDocument %>' />
</ext:GridCommand>
</Commands>
<PrepareToolbar Fn="prepareDownload" />
<DirectEvents>
<Command IsUpload="true" OnEvent="manageDocument">
<ExtraParams>
<ext:Parameter Name="command" Value="command" Mode="Raw" />
<ext:Parameter Name="id" Value="record.data.Id" Mode="Raw"/>
<ext:Parameter Name="contentType" Value="record.data.ContentType" Mode="Raw"/>
<ext:Parameter Name="originalName" Value="record.data.OriginalName" Mode="Raw"/>
<ext:Parameter Name="documentType" Value="record.data.DocumentType" Mode="Raw"/>
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>
<ext:CommandColumn runat="server" Width="30">
<Commands>
<ext:GridCommand Icon="Delete" CommandName="Delete">
<ToolTip Title='<%$ I18n: Tooltip_DeleteDocument %>' />
</ext:GridCommand>
</Commands>
<PrepareToolbar Fn="prepareDelete" />
<DirectEvents>
<Command IsUpload="true" OnEvent="manageDocument">
<ExtraParams>
<ext:Parameter Name="command" Value="command" Mode="Raw" />
<ext:Parameter Name="id" Value="record.data.Id" Mode="Raw"/>
<ext:Parameter Name="contentType" Value="record.data.ContentType" Mode="Raw"/>
<ext:Parameter Name="originalName" Value="record.data.OriginalName" Mode="Raw"/>
<ext:Parameter Name="documentType" Value="record.data.DocumentType" Mode="Raw"/>
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>
<ext:Column runat="server" ColumnID="Id" Header="Id" Hidden="true" DataIndex="Id" />
<ext:Column runat="server" Header='<%$ I18n: Label_OriginalName %>' Hidden="true" DataIndex="OriginalName" />
<ext:BooleanColumn runat="server" Header='<%$ I18n: Label_HasDocumentContent %>' Hidden="true" DataIndex="HasDocumentContent" />
<ext:Column runat="server" Header='<%$ I18n: Label_DocumentName %>' DataIndex="DocumentName" flex="1" />
<ext:Column runat="server" Header='<%$ I18n: Label_DocumentType %>' Width="120" DataIndex="DocumentType" />
<ext:Column runat="server" Header='<%$ I18n: Label_ContentType %>' Width="90" DataIndex="ContentType" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="DocumentsRowSelectionModel" runat="server" SingleSelect="true">
<Listeners>
<Select Handler="documentSelected(#{DocumentsGridPanel}.getSelectio nModel().getSelection()[0].getId());" />
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
</Items>
</ext:Container>
</items>
</ext:Viewport>
</form>
</body>
</html>

Daniil
Mar 08, 2013, 4:32 PM
Hi @sisa,

DirectEventConfig in v1 affects during a Store's load, save or submit requests.

The Command DirectEvents in your example seems to be not related to these actions.

So, the problem is unclear for me.

Could you, please, provide a runnable sample to reproduce?