enabling keypress in fields
in extjs API docs at http://www.extjs.com/deploy/dev/docs it's mentioned you can attach key events, however in config it never list the enableKeyEvents parameters (forgot about it??). So basically what you need to do is add the parameter then attach the events as such:
var field = new Ext.form.TextField({ enableKeyEvents: true }); field.on('keypress', function() { //set code });
thats all... if your keypress still not working, just ensure you are working on ext 2.1 ![]()
rpl a handy shell find and replace strings in file
I had 16000 over static html files in my server that I wanted to edit. Most of guides for doing this through shell command lines all pointed to either find, sed, awk or grep command, I found this very handy utility called "rpl". Well basically sed can do what rpl does, however when i tried with html tags i always got error :(, yeah cos I don't know how to use the sed syntax :).
anyway just apt-get it (apt-get install rpl) and it's ready to run...
a simple command from rpl thats saves me lotsa of time
:
rpl -R -x .php -x .html -x .htm '</body>' '<?php include "myads.php"; ?></body>' *
as you see, I was trying to insert php tags just before the body html tags, thats it, much simpler than sed :).
anyway just curious to all bashers out there, how would you guys do it in awk, sed or grep?...
JSONstore on XTemplate
I can't find any samples using XTemplate usinng JSONstore directly without using dataview or other component. I just wanted to use XTemplate with JSONstore loaded from the server directly... thats it :).
Somehow i always got path error when rendering xtemplate with jsonstore in a dataview, if not 'path' error then I will get 'values' has no property error :(.
anyway managed to create the XTemplate using jsonstore without using dataview.
var tpl = new Ext.XTemplate( ' <table id="history-table">', ' <tr class="heading"> <td> </td> <td>Membership</td> <td>Issue Date</td> <td>Expiry Date</td> </tr> ', '<tpl for=".">', '<tpl if="Ext.isEmpty(values.FIELD_1) == false">', ' <tr class="{[xindex % 2 === 0 ? "odd" : "even"]}">', ' <td>{#}</td> ', ' <td>{FIELD_1}</td> ', ' <td>{FIELD_2}</td> ', ' <td>{FIELD_3}</td> ', '</tr> ', '</tpl>', '<tpl if="Ext.isEmpty(values.FIELD_1) == true">', ' <tr class="{[xindex % 2 === 0 ? "even" : "odd"]}">', ' <td colspan="4">No membership found</td> ', '</tr> ', '</tpl>', '</tpl>', '</table> ', ' <div class="x-clear"></div> ' ); var store = new Ext.data.JsonStore({ url: 'index.php?page=data&entity=table1&search[ID]=20', root: 'rows', autoLoad: true, fields: [ {name: 'counter'}, {name: 'ID',type :'string',sortType:'asText'}, {name: 'FIELD_1',type :'string',sortType:'asText'}, {name: 'FIELD_2',type :'string',sortType:'asText'}, {name: 'FIELD_3',type :'string',sortType:'asText'} ] ,listeners: { 'load': {fn: function(){ tpl.overwrite('20-membershipinfo',store.reader.jsonData.rows, true); } } } });
as you see, the xtemplate data only applied after load using the listeners event. If I don't do using listeners, example execute store.load() followed by tpl.overwrite('20-handheldinfo',store.reader.jsonData.rows, true); I will always get values error... seems the data is not loaded immediately after the load() functions... anyway this code will be better without using extra component like dataview just to show this data ![]()
oh spider don’t come visit me please!
I do love web spiders, you know those search engines spiders that crawls to your website and visit each of your links so that it will be indexed by the search engine... well for the last two days I had a hell from one of the spider... IT BRINGS MY SITE DOWN!!!
Last two days i received an email alert from my own scripts that monitor my sites availability. My server was very slow for the past two days and when I checked the server processes there were so many process. I was thinking that the same incident happened like before, but it was not!, it is what the term called "rapid fire".
Extracting RAR file with password
I have many password protected archives. Just to remind myself on the linux command to extract the archive with the password:
unrar e -p [filename]
once entered, the password will be prompted, and there it is
GoogleMap using postal code in Singapore
It's a mistake!
I thought I could do googlemapping just based on postal code. Well, it does can do google mapping based on postal code but not yet on Singapore!.
Reason? I think simply singapore postal code is not made publicly available by singpost. If you want it, you need to get it from Singpost and pay for the subscription fee.
