Skip to content

Posts tagged ‘Programming’

12
Feb

Sencha Architect: How to use ViewModel to Bind Store into Grid Panel

In ExtJs (5+), one of the major features is MVVM (Model-View-ViewModel). It is an alternative approach of MVC. Basically, MVVM enables each view component have it’s own ViewController and ViewModel classes. This offers a number of benefits, better code management, smaller memory footprint, and better integration with automated tests. In this article, we explore how to use Sencha Architect to setup ViewModel relationship.
Read more »

11
Feb

PyQt: How to hide top level nodes in tree view

In Qt treeview, hidding top level nodes is different to hidding lower level nodes. Lets start with a simple treeview example with two non-empty branches. Here is the code:
Read more »

9
Jan

ExtJs5: Notes on Collapsing Panel in BorderLayout

Suppose we have a panel with borderlayout. The center region is a tab panel with two tabs: Expand and Collapse, whereas the south region is a collapsible panel. The whole idea is to program by clicking ‘Expand’ and ‘Collapse’ tabs which will automatically expand and collapse the south panel respectively. The following is the screenshot:

screen
Read more »

9
Jan

ExtJs: button handler for downloading files

I need to create a ExtJs button for downloading files from time to time. Here is the code I normally use. I put it here for my own reference:

MyApp.download = function(url) {

    // Keep using the same iframe
    var iframe = Ext.get('downloadIframe');
    iframe && Ext.destroy(iframe);

    Ext.DomHelper.append(document.body, {
        tag: 'iframe',
        id:'downloadIframe',
        frameBorder: 0,
        width: 0,
        height: 0,
        css: 'display:none;visibility:hidden;height: 0px;',
        src: url
    });
};

Standard Php code for downloading a file:

      $filepath = "/path/to/file";
      header("Content-Disposition: attachment; filename=\"" . basename($filepath) . "\"");    
      header("Content-Type: application/force-download");
      header("Content-Description: File Transfer");             
      header("Content-Length: " . filesize($filepath));
      readfile($filepath);
23
Dec

Creating a simple fancy HTML list inside a ExtJs Panel

In this blog, we explore how we can quickly assemble a HTML list within a ExtJs Panel. First we use Sencha Cmd to create a simple app  (See this for tutorial). Below is our first approach to launch the app:

Ext.application({
    name: 'Demo',

    extend: 'Demo.Application',

    // autoCreateViewport: 'Demo.view.main.Main'

    launch: function() {
        var win = Ext.create('Ext.window.Window', {
            title: 'Demo',
            width: 500,
            height: 350,            
            html: '<div id="welcome">Welcome to the iTrinegy Demo</div><div id="home_logo"></div><div id="status_list"></div>',
            bodyPadding: '20 15 15 15'
        }).show();
    }
});

Read more »

2
Oct

Styling Qt QTreeView with CSS

Qt offers additional CSS settings such as sub-control and pseudo-states. Although there are reference and brief tutorial with examples, it doesn’t really show how this settings affect the overall look. In this article, we explore how to style the QTreeView via CSS in step by step. First of all, we use a simple treeview directory program (Python/Qt5 ) from this example and style it gradually.
Read more »

8
Sep

Javascript: How to really check for an object property exists

In Javascript, undefined is a value and it can be assigned to properties. So strictly speaking, we shouldn’t use undefined to check for whether an object’s property is defined.

var foo = new Object();
foo.fieldUndefined = undefined;

Read more »

30
Jun

Python 3: __del__ method and imported modules

My python script generates the following error and the strange thing is that this error only occurs occasionally:

Exception AttributeError: "'NoneType' object has no attribute 'path'" in 
<bound method Client.__del__ of <__main__.MyObject object at 0x108c3dc50>> ignored

Read more »

1
Feb

Converting HTML document with IMG src link to IMG embedded data in PHP

In my previous blog, I need to convert a HTML document with IMG src link to IMG with embedded base64 image content. Here is a PHP script that scans the HTML document and replace the IMG tags with embedded content, i.e. changing from this

<img src='./4/data.png'/>

to that

<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhE....

Read more »

12
Jun

[Updated] ExtJs 4.2: Changing column’s editor dynamically in ExtJS RowEditor

ExtJs 4 Row EditorA while ago I have written a blog on how to change the field type inside a row editor dynamically with ExtJs 3. Since then I received a number of requests for the same example in ExtJs 4. It has been way overdue, so here it is.

An online demo is available in joekuan.org and the source code can found in github.