Kendo TreeView indeterminate checkbox for remote datasource and ondemand loading

The task is to create a Treeview within a web application. The Treeview will contain more than 1k nodes in total and every node should have a checkbox to provide information about the check state of nodes within the tree. Checkboxes can have three states (checked, unchecked and indeterminate for parents where only some children are checked). I used Kendo UI Treeview component to solve the task. The problem was to get the indeterminate state of the checkboxes set without loading all the childnodes into the Treeview. For sure on server site the state information for every node has to be available.

My Solution:
Create a KendoUI Treeview with a checkbox template. Within that template add an attribute (here “data-indeterminate”) in case node is in indeterminate state. Additionally bind an event handler for DataBound (here “updateTree”).

@(Html.Kendo().TreeView()
    .Checkboxes(checkboxes =>
    {
        checkboxes.CheckChildren(true);
    })
    .LoadOnDemand(true)
    .DataTextField("Name")
    .Events(e => e.DataBound("updateTree"))
    .CheckboxTemplate("<input type='checkbox' name='checkedNodes' value='#= item.id #' #if(item.checked) { # checked # } if(item.indeterminate) { # data-indeterminate # } #/>")
    .DataSource(dataSource => dataSource.Read(read => read.Action("GetNodes", "TreeView")))
)

In the event handler for Treeview event DataBound find all input tags of type checkbox with attribute data-indeterminate and set the indeterminate state to true.

function updateTree() {
    $('input:checkbox[data-indeterminate]').each(function () {
        $(this)[0].indeterminate = true;
    });
};

This solution works pretty well for readonly Treeview.

Advertisements

Azure Web / Worker Role in virtual networks

I want to reach from my Azure Webrole an on-premise webservice. But I don’t want to make my on-premise Webservice public available. Site to Site connection sounds to be the solution. (see MSDN http://msdn.microsoft.com/en-us/library/windowsazure/jj156206.aspx). But is it possible to to add Azure Web and Workroles to a virtual network created?

YES!

The configuration of a virtual network for Web and Workerroles (PaaS) is diffrent to the configuration of a virtual network for a VM (IaaS). While managementportal gives the opportunity to configure a virtual network for a VM there is no such choice when creating a CloudService. In fact that makes sense as a CloudService can host multiple Web and Workerroles. The network configuration for Web and Workerroles is done in the cloud service configuration (*.cscfg) file. There is currently no wizard provided to add the configuration. Add the following configuration to your CloudService config to add your Web and Workerroles to an existing virtual network.

<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration>
  <!-- configuration of your roles -->
  <NetworkConfiguration>
    <VirtualNetworkSite name="[network name]" />
    <AddressAssignments>
      <InstanceAddress roleName="[role name]">
        <Subnets>
          <Subnet name="[name of subnet]" />
        </Subnets>
      </InstanceAddress>
      <InstanceAddress roleName="[role name]">
        <Subnets>
          <Subnet name="[name of subnet]" />
        </Subnets>
      </InstanceAddress>
    </AddressAssignments>
  </NetworkConfiguration>
</ServiceConfiguration>