Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-130] API - Composite Views

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:52:05.000+0000
Affected Version/sn/a
Fix Version/sRelease 0.7.0
ComponentsiOS
Labelscompositeview
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:24:06.000+0000
Updated2011-04-17T01:52:05.000+0000

Description

Purpose

Composite views are made up of one or more views (i.e., WebView, GroupedView, TableView, or ScrollableView). Composite Views allow you to absolutely size and position views on the page.

See this discussion for more background:

https://appcelerator.lighthouseapp.com/projects/32238/tickets/125-layouts-are-too-limited#ticket-125-18"> https://appcelerator.lighthouseapp.com/projects/32238/tickets/125-l...

API Spec


//Set up views
var table = Titanium.UI.createTableView(...);
var webView = Titanium.UI.createWebView(...);
var webView2 = Titanium.UI.createWebView(...);
var webView3 = Titanium.UI.createWebView(...);

// create composite view
var compositeView = Titanium.UI.createCompositeView();

// add views 
compositeView.addView(webView,{y:0,height:100});
compositeView.addView(webView2,{height:100});
compositeView.addView(table,{y:100, height:50});
compositeView.addView(webView3,{x:60,y:300,width:150,height:50,zIndex:2});

//
// Notes: 
// - if no width is provided, the assumption is 100%
// - height should be required
// - zIndex enables layering of views

// add view
Titanium.UI.currentWindow.addView(compositeView);

// show view
Titanium.UI.currentWindow.showView(compositeView);

Comments

  1. Pawan Poudel 2011-04-15

    Hi,

    I am trying to update the content of a tableview inside a composite view. I created a new table view with updated data and replaced the original table view since I couldn't find a way to update the "data" property of the original tableview. Please see the code below. Even though it works for me, there must be a better way to do this. Please advise.

       function updateTableViewInsideCompositeView() {
         // create a new table view since I don't know 
         // how to update the tableview data
         var updatedTable = Titanium.UI.createTableView({data:newData},function({}));  
       
         // get views
         var views = Titanium.UI.currentWindow.getViews();
           
         // create a new composite view
         var newCompositeView = Titanium.UI.createCompositeView();
           
         // add views 
         newCompositeView.addView(webView,{y:0,height:100});
         newCompositeView.addView(webView2,{height:100});
         newCompositeView.addView(updatedTable,{y:100, height:50});
         newCompositeView.addView(webView3,{x:60,y:300,width:150,height:50,zIndex:2});
           
         // add view
         Titanium.UI.currentWindow.addView(newCompositeView);
       
         // show view
         Titanium.UI.currentWindow.showView(newCompositeView);
       }
       

    Thank you very much,
    Pawan Poudel

  2. Nolan Wright 2011-04-15

    you can update a table view. see Kitchen Sink -
    tableview_update.html (you can also insert new rows, delete rows,
    append rows, and reset the data for the entire table view)

JSON Source