Wijmo 2013 v1 Webcast

Thanks to everyone that showed up for our webcast this week. It had record breaking attendance here at ComponentOne! If you missed it or want to share or watch it again, here is the recording.

Video

Join Sheela Nath and Chris Bannon as they unveil new technology from Team Wijmo. Wijmo 2013 v1 was a major release that added jQuery Mobile support, new widgets and a powerful spreadsheet component. We have been solidifying our framework and creating a platform for HTML5 development. Come take a tour through Wijmo 2013 v1.

Samples

These samples will be integrated into our download soon. But for now you can download them here.

You can also try out AppView and SpreadJS from our online demos. And don’t forget to download wijmo and start building great mobile applications.

Slides

Using Knockout with the WijCarousel

Recently added with the release 2013v1 of Wijmo was an addition to the Knockout library enabling two way bindable functionality for the Data of the WijCarousel. This is perfect for those who want to manage the content of their carousel on the fly.

In this example, I have decided to combine the checkbox functionality of the WijTree with the data of the WijCarousel.

I will treat each value within the Tree as a “node”, meaning that they will all have their own specific properties as defined within the Model…

function PictureNode(url, text)
{
        this.imageUrl = url,
        this.caption = text,
        this.text = text
}

The “imageUrl” and “caption” properties are both necessary to insert pictures with captions into the WijCarousel, while the “text” property is used within the WijTree.

In order to populate the nodes within the WijTree, I will create two ko.observableArray’s.

self.west = ko.observableArray([]);
self.east = ko.observableArray([]);

For each of the WijTree’s, I will set the “nodes” option to their specific array, as well as set several properties.

<ul id="westTree"data-bind="wijtree: {disabled: disabled, allowDrag: allowDrag, allowDrop:allowDrop,
    nodes: west, showCheckBoxes: showCheckBoxes, nodeCheckChanged: nodeCheckChangedWest }">
</ul>

For each of the WijCarousel’s, I will also create two ko.observableArrays, and push some initial data into them.

self.visNodesWest = ko.observableArray([
     new PictureNode("http://wijmo.com/files/img/logos/Hawks.png", "Chicago Blackhawks")
]);
self.visNodesEast = ko.observableArray([
     new PictureNode("http://wijmo.com/files/img/logos/Pens.png", "Pittsburgh Penguins")
]);

I will then do the data-bind for the WijCarousel, by setting the “data” option to each array, as well as set several more options.

<div id="westCaro" data-bind="wijcarousel:{data:visNodesWest,showTimer:showTimer,
      display:display, auto:auto, interval:interval}" style="height:200px;"></div>

The WijTree has a built in function nodeCheckChanged, which will trigger anytime an option with in tree is checked or unchecked. I will trigger this function each time a change is made, and use Knockout to fill each array of the array’s bound to the Carousel.

self.nodeCheckChangedWest = function(e,data)
{
	self.visNodesWest.remove(function(item){return item.text != "Chicago Blackhawks"});
	var nodes = $(this).wijtree("getCheckedNodes");

	$.each(nodes, function(index, elem)
	{
        	var text = $(elem).wijtreenode('option', 'text');
        	var url = $(elem).wijtreenode('option', 'imageUrl');
		self.visNodesWest.push(new PictureNode(url,text));
	});
};

When running, you will notice that once the team name is checked, the image will be added/removed from the WijCarousel.

This is a great way to let Knockout do all the heavy lifting for you, as well as create a live interface for your end user.

Let’s go Pens!

Sample code can be found here.

How To Set Cell Value in SpreadJS

SpreadJS provides many ways to assign value to cells, you can choose any one of options below to set value of cells.
1. setValue/setText method
Sheet object of SpreadJS has a method setValue, this method can be used to set value to any cell in viewport or headers by specific row and column index. The value can be any type of data like string, date time, boolean, number. In addition, the Sheet object has another method setText, you can use this method to set text to any cell in either viewport or header.

sheet.setValue(0,2,"ColumnHeader", $.wijmo.wijspread.SheetArea.colHeader);
sheet.setValue(2,0,"RowHeader", $.wijmo.wijspread.SheetArea.rowHeader);
sheet.setValue(2,2,"viewport", $.wijmo.wijspread.SheetArea.viewport);

2. Set value by Cell object
Sheet object has two methods getCell and getCells, you can use them to get a Cell object which indicates a specific cell, or a range of cells, and use value/text method of Cell object to set value to a cell or a range of cells.

sheet.getCell(0,0).text("cell");
sheet.getCells(1,1,3,3).value("range");


3. Binding to JSon array
You can create a JSON array, and bind it to Sheet object by using the setDataSource method.

var arr = [
{"Series0":2,"Series1":1},
{"Series0":4,"Series1":2},
{"Series0":3,"Series1":4}
];
sheet.setDataSource(arr);


4. Import CSV text
You can import a CSV text string into a range of cells by using the setCsv method of Sheet object.

var csv = "1,2,3;a,b,c";
sheet.setCsv(1,1,csv,";",",");

You can try all of the above code in a web page which has initialized SpreadJS, to learn more about getting started with SpreadJS in a web page, please read Quick Start Guide to Using SpreadJS.

For more information about how to use SpreadJS, includes its data model and API, please read our online documentation or try online demos.