[CLOSED] MultiUpload Grid Question

  1. #1

    [CLOSED] MultiUpload Grid Question

    I am using the MultiUpload Grid perfectly fine but now i need to do some modification on the Grid , i have added a component column and included a combobox. in code behind when i am uploading the file i need to get that value of that combobox that i added.
    Here is my UploadGrid

      <ext:GridPanel
                                ID="UploadGrid"
                                runat="server"
                                Flex="1"
                                Frame="true">
                                <Store>
                                    <ext:Store ID="Store1" runat="server">
                                        <Model>
                                            <ext:Model ID="Model1" runat="server" IDProperty="id">
                                                <Fields>
                                                    <ext:ModelField Name="id" />
                                                    <ext:ModelField Name="FileType" />
                                                    <ext:ModelField Name="name" />
                                                    <ext:ModelField Name="size" />
                                                    <ext:ModelField Name="status" />
                                                    <ext:ModelField Name="progress" />
                                                </Fields>
                                            </ext:Model>
                                        </Model>
                                    </ext:Store>
                                </Store>
                                <ColumnModel>
                                    <Columns>
    
                                        <ext:ComponentColumn ID="ComponentColumn1" runat="server" DataIndex="FileType" Text="File Type">
                                            <Component>
                                                <ext:ComboBox ID="ComboBox1" runat="server" DisplayField="ApplicationFileTypeName" ValueField="ApplicationFileTypeId" ForceSelection="true" QueryMode="Local">
                                                    <Store>
                                                        <ext:Store runat="server" ID="storeFileType" DataSourceID="dtsFileType">
                                                            <Model>
                                                                <ext:Model ID="Model2" runat="server" IDProperty="ApplicationFileTypeId">
                                                                    <Fields>
                                                                        <ext:ModelField Name="ApplicationFileTypeName" Type="String"></ext:ModelField>
                                                                        <ext:ModelField Name="ApplicationFileTypeId" Type="Int"></ext:ModelField>
    
                                                                    </Fields>
                                                                </ext:Model>
    
                                                            </Model>
    
                                                        </ext:Store>
    
                                                    </Store>
    
                                                </ext:ComboBox>
    
                                            </Component>
    
                                        </ext:ComponentColumn>
    
                                        <ext:Column ID="Column1" runat="server" Text="File Name" DataIndex="name" Width="150" />
                                        <ext:Column ID="Column2" runat="server" Text="Size" DataIndex="size" Width="60">
                                            <Renderer Format="FileSize" />
                                        </ext:Column>
                                        <ext:Column ID="Column3" runat="server" Text="&nbsp;" DataIndex="status" Width="30">
                                            <Renderer Fn="statusIconRenderer" />
                                        </ext:Column>
                                        <ext:Column ID="Column4" runat="server" Text="Status" DataIndex="status" Width="60" />
                                        <ext:ProgressBarColumn ID="ProgressBarColumn1" runat="server" Text="progress" DataIndex="progress" />
                                    </Columns>
                                </ColumnModel>
                                <TopBar>
                                    <ext:Toolbar ID="Toolbar1" runat="server">
                                        <Items>
                                            <ext:MultiUpload
                                                ID="MultiUpload1"
                                                runat="server"
                                                OnFileUpload="MultiUpload1_FileUpload"
                                                FileDropAnywhere="true"
                                                FileSizeLimit="15 MB"
                                                FileTypes="*.*"
                                                FileTypesDescription="All Files"
                                                FileUploadLimit="100"
                                                FileQueueLimit="0">
                                                <Listeners>
                                                    <SwfUploadLoadFailed Fn="loadFailed" />
                                                    <FileSelected Fn="fileSelected" />
                                                    <UploadStart Handler="updateRecord(file.id, 'status', 'Sending');" />
                                                    <UploadProgress Handler="updateRecord(file.id, 'progress', Math.round(bytesComplete / bytesTotal));" />
                                                    <UploadComplete Handler="updateRecord(file.id, 'progress', 1 );updateRecord(file.id, 'status', 'Uploaded' );" />
                                                    <UploadAborted Handler="updateRecord(file.id, 'status', 'Aborted');" />
                                                    <UploadRemoved Handler="var store = this.up('grid').store; store.remove(store.getById(file.id));" />
                                                    <UploadError Fn="uploadError" />
                                                    <FileSelectionError Fn="fileSelectionError" />
                                                </Listeners>
                                                
                                            </ext:MultiUpload>
    
                                            <ext:ToolbarSeparator />
    
                                            <ext:Button ID="Button3"
                                                runat="server"
                                                Text="Start Upload"
                                                Icon="Tick"
                                                Handler="#{MultiUpload1}.startUpload();">
                                            </ext:Button>
    
                                            <ext:Button ID="Button4"
                                                runat="server"
                                                Text="Abort"
                                                Icon="Decline"
                                                Handler="abortUpload" />
                                            <ext:Button ID="Button5"
                                                runat="server"
                                                Text="Abort All"
                                                Icon="Decline"
                                                Handler="#{MultiUpload1}.abortAllUploads();" />
                                            <ext:Button ID="Button6"
                                                runat="server"
                                                Text="Remove"
                                                Icon="Delete"
                                                Handler="removeUpload" />
                                            <ext:Button ID="Button7"
                                                runat="server"
                                                Text="Remove All"
                                                Icon="Delete"
                                                Handler="#{MultiUpload1}.removeAllUploads();" />
                                        </Items>
                                    </ext:Toolbar>
                                </TopBar>
                            </ext:GridPanel>
    Here is my codebehind

     Public Sub MultiUpload1_FileUpload(sender As Object, e As Ext.Net.FileUploadEventArgs)
    
            Dim filePath As String = e.FileName
            Dim filename As String = Path.GetFileName(filePath)
            Dim ext As String = Path.GetExtension(filename)
            Dim contenttype As String = String.Empty
    
            'Set the contenttype based on File Extension
            Select Case ext
                Case ".doc"
                    contenttype = "MS Word [doc]"
                    Exit Select
                Case ".docx"
                    contenttype = "MS Word [docx]"
                    Exit Select
                Case ".xls"
                    contenttype = "Ms Excel [xls]"
                    Exit Select
                Case ".xlsx"
                    contenttype = "Ms Excel [xlsx]"
                    Exit Select
                Case ".jpg"
                    contenttype = "Image [jpg]"
                    Exit Select
                Case ".png"
                    contenttype = "Image [png]"
                    Exit Select
                Case ".gif"
                    contenttype = "Image [gif]"
                    Exit Select
                Case ".pdf"
                    contenttype = "Document [pdf]"
                Case ".zip"
                    contenttype = "Folder [zip]"
                Case ".7z"
                    contenttype = "Folder [7 zip]"
                Case ".rar"
                    contenttype = "Folder [rar]"
                    Exit Select
            End Select
    
            If contenttype <> String.Empty Then
                Dim fs As Stream = e.PostedFile.InputStream
                Dim br As New BinaryReader(fs)
                Dim bytes As Byte() = br.ReadBytes(fs.Length)
    
                'insert the file into database
                Dim strQuery As String = "insert into Files" _
                & "(ApplicationId,FileName, ContentType,CreateDatetime, Data)" _
                & " values (@ApplicationId,@Name, @ContentType,@CreateDateTime, @Data)"
                Dim cmd As New SqlCommand(strQuery)
                cmd.Parameters.Add("@CreateDatetime", SqlDbType.DateTime).Value = DateTime.Now
                cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = filename
                cmd.Parameters.Add("@ContentType", SqlDbType.VarChar).Value _
                = contenttype
                cmd.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes
                cmd.Parameters.Add("@ApplicationId", SqlDbType.Int).Value = 5000
                InsertUpdateData(cmd)
    
    
    
                ExtNet.Msg.Notify("Upload", e.FileName).Show()
    
    
            Else
    
                ExtNet.Msg.Notify("Upload", "Can not upload </br>", e.FileName).Show()
    
            End If
    Last edited by Daniil; Jan 14, 2014 at 7:38 AM. Reason: [CLOSED]
  2. #2
    Hi @ebeker,

    Let's consider this example.
    https://examples2.ext.net/#/MultiUpload/Basic/Grid/

    1. Add this for the MultiUpload.
    <CustomConfig>
        <ext:ConfigItem Name="buildPostParams" Value="buildPostParams" Mode="Raw" />
    </CustomConfig>
    2. Add this into the page's <head>.
    <script>
        var buildPostParams = function(file) {
            var record = App.UploadGrid.store.findRecord("name", file.name);
    
            return { // an object with arbitrary parameters
                myParameter: record.data.size
            };
        };
    </script>
    3. Get "myParameter" on server via Request.
    protected void MultiUpload1_FileUpload(object sender, FileUploadEventArgs e)
    {
        X.Msg.Notify("File is uploaded", "Name: " + e.FileName + "<br/>My parameter: " + this.Request["myParameter"]).Show();
    }
  3. #3
    I forgot about a MultiUpload's PostParams.

    The solution above can be replaced with
    <ext:MultiUpload runat="server">
        <PostParams>
            <ext:Parameter Name="myParameter" Value="getMyParameter(file)" Mode="Raw" />
        </PostParams>
    </ext:MultiUpload>
    var getMyParameter = function(file) {
        var record = App.UploadGrid.store.findRecord("name", file.name);
    
        return record.data.size;
    };

Similar Threads

  1. [CLOSED] Multiupload ErrorCode
    By vzx in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Apr 30, 2014, 11:24 AM
  2. MultiUpload MVC Razor Where is OnFileUpload
    By qadir0108 in forum 2.x Help
    Replies: 1
    Last Post: Jan 01, 2014, 8:29 AM
  3. [CLOSED] MultiUpload Get All Files
    By vzx in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 27, 2013, 7:38 AM
  4. [CLOSED] Multiupload error code
    By Digital.Dynamics in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 23, 2013, 4:32 AM
  5. MultiUpload how to access to PostParams
    By xtremexploit in forum 2.x Help
    Replies: 2
    Last Post: Oct 31, 2013, 9:09 PM

Tags for this Thread

Posting Permissions