[1.3] Is bug for fileupload in PropertyGrid?

  1. #1

    [1.3] Is bug for fileupload in PropertyGrid?

    Hi,Dear Sir:

    I place a fileupload control in propertygrid, my code like this:


    <ext:PropertyGrid ID="gridProperties" runat="server" Width="260" Icon="Cog" Title="tools"
                Collapsible="true" Split="true" Region="East" Margins="0" Layout="Fit">
              
                <Source>
                    
                    <ext:PropertyGridParameter Name="bg" Value="">
                        <Editor>
                          <ext:FileUploadField ID="felSDishNameImg" runat="server" EmptyText="please selected a photo" 
                                ButtonText="" Icon="ImageAdd" AnchorHorizontal="95%" >
                            
                          </ext:FileUploadField>
                        </Editor>
                    </ext:PropertyGridParameter>
                </Source>
                <View>
                    <ext:GridView ID="GridView1" ForceFit="true" ScrollOffset="2" runat="server" />
                </View>
            </ext:PropertyGrid>

    but the fileupload button can't trigger,is it a bug for propertygrid?
    Last edited by Daniil; Apr 23, 2012 at 7:40 AM. Reason: Please use [CODE] tags
  2. #2
    Hi,

    I would not consider it a but. Just FileUploadField is a too specific field.

    You can set up
    allowBlur : false
    for the editor to avoid the behavior you described.

    But a file won't be submitted, because the FileUploadField is rendered outside of <form>.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Submit(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Submit", this.Request.Files.Count).Show();
        }
    </script>
    
    <!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>Ext.NET Example</title>
    
        <script type="text/javascript">
            var onViewReady = function (grid) {
                var editor = grid.getColumnModel().getCellEditor(1, 0);
    
                editor.allowBlur = false;
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Button runat="server" Text="Test" OnDirectClick="TestDirectEventHandler" />
    
            <ext:PropertyGrid ID="PropertyGrid1" runat="server" Width="400" AutoHeight="true">
                <Source>
                    <ext:PropertyGridParameter Name="File">
                        <Editor>
                            <ext:FileUploadField runat="server">
                                <Listeners>
                                    <FileSelected Handler="PropertyGrid1.stopEditing();" />
                                </Listeners>
                            </ext:FileUploadField>
                        </Editor>
                    </ext:PropertyGridParameter>
                </Source>
                <Listeners>
                    <ViewReady Fn="onViewReady" />
                </Listeners>
            </ext:PropertyGrid>
        </form>
    </body>
    </html>
    Finally, if you need to submit a file (you, obviously, will need it) I can suggest the following solution.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Submit(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Submit", this.Request.Files.Count).Show();
        }
    </script>
    
    <!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>Ext.NET Example</title>
    
        <script type="text/javascript">
            var onViewReady = function (grid) {
                var editor = grid.colModel.getCellEditor(0, 0);
    
                editor.allowBlur = false;
            };
    
            var onTriggerClick = function (field) {
                var menu = Menu1,
                    el = field.getEl();
    
                if (!menu.rendered) {
                    menu.render();
                }
    
                menu.showAt([el.getLeft(), el.getBottom()]);
            };
    
            var onFileSelected = function (fileField) {
                var menu = Menu1,
                    grid = PropertyGrid1,
                    editor = grid.activeEditor;
    
                editor.setValue(fileField.getValue());
                menu.hide();
                grid.stopEditing();
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:PropertyGrid ID="PropertyGrid1" runat="server" Width="200" AutoHeight="true">
                <Source>
                    <ext:PropertyGridParameter Name="File">
                        <Editor>
                            <ext:TriggerField runat="server">
                                <Triggers>
                                    <ext:FieldTrigger Icon="SimpleAdd" />
                                </Triggers>
                                <Listeners>
                                    <TriggerClick Fn="onTriggerClick" />
                                </Listeners>
                            </ext:TriggerField>
                        </Editor>
                    </ext:PropertyGridParameter>
                </Source>
                <Listeners>
                    <ViewReady Fn="onViewReady" />
                </Listeners>
            </ext:PropertyGrid>
    
            <ext:Button runat="server" Text="Submit" OnDirectClick="Submit" />
    
            <ext:Menu 
                ID="Menu1" 
                runat="server"
                RenderToForm="true">
                <Items>
                    <ext:ComponentMenuItem runat="server" Shift="false">
                        <Component>
                            <ext:FileUploadField runat="server" Width="300">
                                <Listeners>
                                    <FileSelected Fn="onFileSelected" />
                                </Listeners>
                            </ext:FileUploadField>
                        </Component>
                    </ext:ComponentMenuItem>
                </Items>
            </ext:Menu>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] [MVC] FileUpload in MVC
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Jan 27, 2015, 4:03 PM
  2. [CLOSED] [#92] FileUpload
    By Timothy in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Jan 16, 2013, 3:44 AM
  3. Ext.Net fileupload field
    By akwolf in forum 1.x Help
    Replies: 5
    Last Post: Jan 03, 2012, 11:39 PM
  4. Replies: 0
    Last Post: Feb 24, 2010, 10:09 PM
  5. bug in fileupload
    By pablisho in forum 1.x Help
    Replies: 0
    Last Post: Jul 01, 2009, 10:55 AM

Tags for this Thread

Posting Permissions