[CLOSED] dataview double click

  1. #1

    [CLOSED] dataview double click

    Hi,

    Im just playing around with the dataview, and i would like to be able to doubleclick an image and be able to open it in a new window. I know that i have to add a DblClick listener to the dataview but i am having difficulty accessing the selected image.

    Any assistance would be greatly appreciated.

    Lee
  2. #2

    RE: [CLOSED] dataview double click

    Hi Lee,

    I changed 'https://examples1.ext.net/#/DataView/Basic/Overview/' example.

    What I changed
    1. Added listener to the DataView
    <DblClick Handler="showPopUp(this.store.getAt(index).data)" />
    2. Added window which shows image
     <ext:Window ID="ImageWindow" runat="server" Show&#111;nload="false" Width="150" Height="150" Title="Image">
                <Body>
                    <img id="clickedImage" />
                </Body>
            </ext:Window>
    3. Added js function
            showPopUp = function(data) {
                Imagewindow.show(undefined, function() {
                    this.setTitle(data.name);
                    Ext.get('clickedImage').dom.src = data.url;
                }, ImageWindow);
            }
    Here is code of this example (you can replace code in those example by this code for testing)

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.Generic"%>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                string path = Server.MapPath("../../Shared/images/thumbs");
                string[] files = System.IO.Directory.GetFiles(path);
    
                List<object> data = new List<object>(files.Length);
                foreach (string fileName in files)
                {
                    System.IO.FileInfo fi = new System.IO.FileInfo(fileName);
                    data.Add(new { name = fi.Name, 
                                   url = "../../Shared/images/thumbs/" + fi.Name,
                                   size = fi.Length,
                                   lastmod = fi.LastAccessTime });
                }
    
                this.Store1.DataSource = data;
                this.Store1.DataBind();
            }
    
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
        <ext:ScriptContainer ID="ScriptContainer1" runat="server"/>
        
        <script src="data-view-plugins.js" type="text/javascript"></script>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
        
        <script type="text/javascript">
            prepareData = function(data){
                data.shortName = Ext.util.Format.ellipsis(data.name, 15);
                data.sizeString = Ext.util.Format.fileSize(data.size);
                data.dateString = data.lastmod.format("m/d/Y g:i a");
                return data;
            };
                
            selectionChaged = function(dv,nodes){
                var l = nodes.length;
                var s = l != 1 ? 's' : '';
                ImagePanel.setTitle('Simple DataView ('+l+' item'+s+' selected)');
    
            };
    
            showPopUp = function(data) {
                Imagewindow.show(undefined, function() {
                    this.setTitle(data.name);
                    Ext.get('clickedImage').dom.src = data.url;
                }, ImageWindow);
            }
        </script> 
        <style type="text/css">
            .images-view .x-panel-body{
                background: white;
                font: 11px Arial, Helvetica, sans-serif;
            }
            .images-view .thumb{
                background: #dddddd;
                padding: 3px;
            }
            .images-view .thumb img{
                height: 60px;
                width: 80px;
            }
            .images-view .thumb-wrap{
                float: left;
                margin: 4px;
                margin-right: 0;
                padding: 5px;
                text-align:center;
            }
            .images-view .thumb-wrap span{
                display: block;
                overflow: hidden;
                text-align: center;
            }
    
            .images-view .x-view-over{
                border:1px solid #dddddd;
                background: #efefef url(../../Shared/images/row-over.gif) repeat-x left top;
                padding: 4px;
            }
    
            .images-view .x-view-selected{
                background: #eff5fb url(../../Shared/images/selected.gif) no-repeat right bottom;
                border:1px solid #99bbe8;
                padding: 4px;
            }
            .images-view .x-view-selected .thumb{
                background:transparent;
            }
    
            .images-view .loading-indicator {
                font-size:11px;
                background-image:url(../../Shared/images/loading.gif);
                background-repeat: no-repeat;
                background-position: left;
                padding-left:20px;
                margin:10px;
            }
        </style>   
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <h1>DataView Example</h1>
            <p>This example shows how to use a DataView.  It demonstrates basic multi-select (using ctrl or shift) and drag selection.</p>
    
            <ext:Store runat="server" ID="Store1" AutoLoad="true">
                <Reader>
                    <ext:JsonReader>
                        <Fields>
                            <ext:RecordField Name="name" />
                            <ext:RecordField Name="url" />      
                            <ext:RecordField Name="size" Type="Int" />
                            <ext:RecordField Name="lastmod" Type="Date" DateFormat="Y-m-dTh:i:s" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>        
                           
            <ext:Panel 
                runat="server" 
                ID="ImagePanel" 
                Cls="images-view" 
                Frame="true" 
                AutoHeight="true" 
                Width="535" 
                Collapsible="true" 
                Title="Simple DataView (0 items selected)">
                <Body>
                    <ext:FitLayout runat="server">
                        <ext:DataView runat="server"
                            StoreID="Store1"
                            AutoHeight="true"
                            MultiSelect="true"
                            OverClass="x-view-over"
                            ItemSelector="div.thumb-wrap"
                            EmptyText="No images to display" >
                            <Template runat="server">
                                <tpl for=".">
                                    <div class="thumb-wrap" id="{name}">
                                        <div class="thumb"><img src="{url}" title="{name}">
    
                                        {shortName}
                                    
    
                                </tpl>
                                <div class="x-clear">
                                
                            </Template>                         
                                            
                            <Listeners>
                                <SelectionChange Fn="selectionChaged" /> 
                                <DblClick Handler="showPopUp(this.store.getAt(index).data)" />
                            </Listeners>   
                            
                            <Plugins>
                                <ext:GenericPlugin runat="server" InstanceOf="Ext.DataView.DragSelector" />
                            </Plugins>
                        </ext:DataView>
                    </ext:FitLayout>
                </Body>
            </ext:Panel>
            
            <ext:Window ID="ImageWindow" runat="server" Show&#111;nload="false" Width="150" Height="150" Title="Image">
                <Body>
                    <img id="clickedImage" />
                </Body>
            </ext:Window>
        </form>
    </body>
    </html>
    Hope this help


  3. #3

    RE: [CLOSED] dataview double click

    thanks for the quick response.

    I copied and pasted your solution but its giving me "Imagewindow is undefined" when i perform a doubleclick.
  4. #4

    RE: [CLOSED] dataview double click

    Sorry,

    It seems typo. Need use 'ImageWindow' (ClientID of Window)

            showPopUp = function(data) {
                ImageWindow.show(undefined, function() {
                    this.setTitle(data.name);
                    Ext.get('clickedImage').dom.src = data.url;
                }, ImageWindow);
            }

  5. #5

    RE: [CLOSED] dataview double click

    Thanks Vladimir,

    worked a treat!!! You are a scholar and a gentleman!
  6. #6

    RE: [CLOSED] dataview double click



    Hi Vladimir,

    How to get selectedItem name in Code Behind am desperately looking for answer.

Similar Threads

  1. Replies: 2
    Last Post: Aug 04, 2011, 2:14 PM
  2. [CLOSED] TreeView double click
    By majunior in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 10, 2011, 3:35 PM
  3. Double click the row in the grid...
    By Tanielian in forum 1.x Help
    Replies: 1
    Last Post: Sep 03, 2010, 2:23 PM
  4. Fire cell click on row double-click
    By RPIRES in forum 1.x Help
    Replies: 1
    Last Post: Jul 01, 2010, 8:20 PM
  5. [CLOSED] Row double click
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 18, 2008, 8:49 AM

Posting Permissions