Saturday, 29 June 2013

Advanced Layout Design in Sencha Touch 2 - Part2

Today, we are going to see how to design a more complex layout using hboxvbox layouts in Sencha Touch 2. Here is the snapshot of the layout design


Here is the sencha source code for the above layout design.

Ext.define('MyApp.view.LayoutContainer', {
    extend: 'Ext.Container',
    alias: 'widget.layoutcontainer',

    config: {
        itemId: 'layoutcontainer',
        layout: {
            type: 'hbox'
        },
        items: [{
            xtype: 'container',
            flex: 1,
            itemId: 'leftcontainer',
            layout: {
                type: 'fit'
            },
            items: [{
                xtype: 'container',
                height: '100%',
                itemId: 'top-left-red',
                style: 'background-color:red',
                width: '100%',
                layout: {
                    type: 'fit'
                }
            }, {
                xtype: 'panel',
                docked: 'bottom',
                height: '60%',
                itemId: 'bottom-left-green',
                style: 'background-color:green',
                width: '100%',
                layout: {
                    type: 'fit'
                }
            }]
        }, {
            xtype: 'container',
            flex: 1,
            itemId: 'righttcontainer',
            layout: {
                type: 'vbox'
            },
            items: [{
                xtype: 'panel',
                flex: 1,
                height: '50%',
                itemId: 'top-right-blue',
                style: 'border-bottom:1px solid;border-left:1px solid;background-color:blue;',
                width: '100%',
                layout: {
                    type: 'fit'
                }
            }, {
                xtype: 'panel',
                flex: 1,
                height: '50%',
                itemId: 'bottom-right-yellow',
                style: 'border-left:1px solid;background-color:yellow;',
                width: '100%',
                layout: {
                    type: 'fit'
                }
            }]
        }]
    }
});

Important Note: Each itemId configuration value denotes the corresponding display position with color for the above layout snapshot.

Hope, you enjoyed this Post.

12 comments:

  1. When I try to upgrade my gmap version from v2 to v3 I got the like TypeError: this.getMap(...) is undefined


    this.getMap().setCenter(point, this.zoomLevel).I am in bit troble. could you please help me to resolve this isssue. I know this is not related to sencha touch. But I think you can help me to resolve this issue. Expect your help at the earliest.

    Thanks,
    Anu

    ReplyDelete
    Replies
    1. Hi Anu,

      This url explains the necessary steps that you need to follow while upgrading from gmap v2 to v3.

      https://developers.google.com/maps/documentation/javascript/v2/v2tov3

      Hope, this helps!.

      Thanks and Regards,
      Suresh Ariya

      Delete
  2. Load more message is showing even if no records to be laoded. How can we turn off 'Load More' message from sencha touch 2.3 paging plugin.

    ReplyDelete
    Replies
    1. This URL has information regarding how you can hide Load More Message on store.load() callback. Hope, this helps

      http://www.enovision.net/listpaging-plugin-sencha-touch/

      Thanks
      Suresh Ariya

      Delete
  3. Load more issue is again happening when a huge record is loading from the server and when we click on the Load More button the unexpected records listing..how to prevent this issue..

    ReplyDelete
    Replies
    1. Anu,

      I can't able to understand your issue. you mean to say, when i click 'Load More' more records are getting displayed instead of fixed records?

      Delete
    2. Here is my suggestion:

      Try to pass total records to display from Store using 'extraParams' parameter. Then using the extraParams value in the Server side (PHP, Java) to return the exact records as JSON response.

      Delete
    3. nice suggestion..thank you so much

      Delete
  4. hi..I have one doubt in my extjs tree grid.. I have created a tree grid with some columns.. with some context menu..but issue is whenever I tried to add a child under the root node new child is added in the first row.. hw it will add at the end of each record? pls help

    ReplyDelete
    Replies
    1. Anu,

      please try beforeAdd() event method, http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.container.AbstractContainer-event-beforeadd

      Thanks and Regards,
      Suresh Ariya

      Delete