Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use view-compiler for the grid #135

Closed
JeroenVinke opened this issue Dec 12, 2015 · 1 comment
Closed

Use view-compiler for the grid #135

JeroenVinke opened this issue Dec 12, 2015 · 1 comment

Comments

@JeroenVinke
Copy link
Member

Currently being written

Aurelia currently supports two different ways of view compilation: enhance and the view-compiler. The rule of thumb is to use enhance when you have an existing element (such as the <tr>), and when you have a template (but no elements yet) to use the view-compiler.

We are currently using enhance when kendo calls the angular function here, but since compilation is done on a row-to-row basis, performance is pretty bad when virtualization is enabled and a pagesize of 100 is used. So we would like to do compilation of the Grid cells by using the view-compiler.

There are 4 terms you must know to understand the process: ViewCompiler, ViewFactory, View and ViewSlot.

  • The ViewCompiler accepts a template and returns a ViewFactory.
  • The ViewFactory allows you to create Views from an already compiled template.
  • A View is an instantation of a template
  • The ViewSlot represents a slot or location within the DOM to which views can be added and removed. This ViewSlot has to be added to the DOM, which is done by passing in an element when creating a ViewSlot.

In pseudo-code, it looks like this:

    // the ViewFactory compiles the template once
    // and Views should be created for every cell
    let viewFactory = viewCompiler.compile('<span>${bindingExpression}</span>');


    // this is the iterating part
    let view = viewFactory.create();

    // parentElement is the place where we want to insert the ViewSlot
    let viewSlot = new ViewSlot(parentElement, false); 

    // add the View to the ViewSlot
    viewSlot.add(view);

    // initialize binding, by passing the dataItem of the cell as the context
    viewSlot.bind(dataItem);
    viewSlot.attached();

We got the creation of the ViewFactory covered, as we're passing the column template to Kendo's Grid ourselves. However, we need a hook where we have the column that's being rendered, the dataItem of the cell, and the location where we can insert our compiled element in the DOM.

image

@JeroenVinke
Copy link
Member Author

Lets reopen this if performance ever becomes an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant