NNKL.COM
welcome to my space
X
Search:  
 HOME   Directory listing in data view causes file downloads
Directory listing in data view causes file downloads
Published by: wktd 2009-01-08
Welcome to:nnkl.com

  • I have a dataview which loads a directory listing from a php file. It's a relatively simple setup, but for some reason during the Store loading, the files themselves are loaded/cached.

    store: new Ext.data.Store({
    fields: ['url', 'thumbUrl', 'title', 'filetype'],
    sortInfo: {field: 'title', direction: "ASC"},
    proxy: new Ext.data.HttpProxy({url: 'getUploads.php?dir=' + dir}),
    reader: new Ext.data.JsonReader({root: 'uploads'}, ['url', 'thumbUrl', 'title']),
    autoLoad: true,
    listeners: {
    'beforeload': function(ds, records, opts) {
    var t=0;
    },
    'load': function(ds, records, opts) {
    for(var i=0; i var title = records[i].get('title');
    var f = title.substr( title.lastIndexOf('.')+1 );
    records[i].set('filetype', f);

    var fileTypes = {
    'html': 'html',
    ...........
    'xslx': 'spreadsheet'
    };

    if(fileTypes[f] !== 'image') {
    IPM FAQs and Troubleshooting Tips::
    directory listing or initiates the sending or receiving of a file, its connection to the configuration server, real time poller, data view server, or
    http://www.cisco.com/univercd/cc/td/doc/product/rtrmgmt/ipmcw2k/cipm26/uguide/ipmfaq.pdf
    HOME
    records[i].set('thumbUrl', './images/thumbs/' + (fileTypes[f] 'unknown') + '.png');
    }
    records[i].set('title', shorten(title, 20));
    }
    }
    }
    })


    The response is relatively simple:

    {'uploads': [
    {'url':'./uploads/Guthrie1.aif', 'thumbUrl':'./uploads/Guthrie1.aif', 'title':'Guthrie1.aif'},
    {'url':'./uploads/Portal Song.mp3', 'thumbUrl':'./uploads/Portal Song.mp3', 'title':'Portal Song.mp3'},
    {'url':'./uploads/olive.jpg', 'thumbUrl':'./uploads/olive.jpg', 'title':'olive.jpg'},
    {'url':'./uploads/purple.jpg', 'thumbUrl':'./uploads/purple.jpg', 'title':'purple.jpg'}
    ]}


    All I'm loading is the url strings and titles, yet for some reason when the data store is loaded, the files are cached (appear in the NET tab of FireBug).
    So the Portal Song.mp3 (all 5mb) is cached.

    Any reason why?


  • I've never found a good way to put logic into a template. Would you mind giving an example of some basic logic, or better yet, a function call?


  • Ok It wasn't the store that caused it.

    I'm displaying a DataView with file icons. On the store's 'load' event, I'm determining which icon to use for which file, but when it first comes in it was set to use the file itself for the thumbnail (like for images).

    Had to do the work in PHP instead of JS, as I can't determine a way to affect the records after they are in JS, but before they are added to the store.

    It's solved though.


  • Yup! Either do that or you could put in some custom logic in your Template.


  • Yeah, that's what I assumed. There isn't a way to get a listener between when the request is returned and when the records are added, is there?

    I have it working, I'd just rather write it in JS than PHP.


  • Here's my question, in sequential form

    1) Create data store for DataView with autoLoad
    2) 'beforeload' fires (nothing actually done, but the request is fired off)
    3) PHP gets the directory listing and returns this

    {'uploads': [
    {'url':'./uploads/Guthrie1.aif', 'thumbUrl':'./uploads/Guthrie1.aif', 'title':'Guthrie1.aif'},
    {'url':'./uploads/Portal Song.mp3', 'thumbUrl':'./uploads/Portal Song.mp3', 'title':'Portal Song.mp3'},
    {'url':'./uploads/olive.jpg', 'thumbUrl':'./uploads/olive.jpg', 'title':'olive.jpg'},
    {'url':'./uploads/purple.jpg', 'thumbUrl':'./uploads/purple.jpg', 'title':'purple.jpg'}
    ]}

    4) Store loads records from request
    5) 'load' event is fired. JS changes thumbUrl to appropriate thumbnail image based on filetype

    Somewhere between 4 and 5 it's already rendered the DataView, so it attempts to read the thumbUrl as the img src.

    Oh! I got it. I can simply return blank for the thumbUrl since I already get the info I need in the url and title.

    Nevermind. No questions anymore. Thanks.


  • Hrm, I'm unsure of what the question is. I would suggest using an icon for the mp3 for the thumbUrl.


  • This problem is caused by using the thumbUrl. Http will pull down any file regardless of type that is included in a src attribute of an img tag.





  • I Am a Sinner – What About You?
    Global Sourcing and Supplier Online by Dylan

    You are looking at:nnkl.com's Directory listing in data view causes file downloads, click nnkl.com to home
  • how to get more subscribers instantly
  • 5 must know tips for air travel with lighters and matches
  • maintaining areas of your restaurant clean
  • hearing aid improvements can solve your hearing problem
  • in the 21st century with wireless stereo headphones
  • 6 proven reasons for network marketing article marketing
  • loewe concept l32 our view is that overall pretty good but the hi def performance could have been better
  • rss capture the feed however you can
  • utah internet advertising the rights of the self important consumer
  • codependency emotional violence
  • the homemade ice cream cake
  • customer service the network factor
  • pursuit of happiness through best friend
  •  
  • roadmap to riches 141 000 in one day
  • gas price saving tips
  • secrets to beating anxiety
  • living with my aging parents
  • coping with anxiety
  • self talk will help your motivation
  • free traffic information
  • cash and pay per click affiliate programs
  • magnet basics gauss ratings
  • car insurance for college grads how to get the best rate
  • voip for business use
  • making vital connections with a childrens audio bible
  • different types of sugars and sweeteners
  • sony ericsson k510i fortus phone review
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 nnkl.com        Site made:CFZ