JQuery & Knockout - A Simple Example


Hi All,

I have been assigned to do some client side stuff. In this case, we have some FAQ contents in CRM back-end and I want to  grab those content and display it in a user control.

End result will look like this:

We extensively use Knockout.js and jQuery in terms of displaying simple content. The advantage of this is that it renders much faster than using server controls. To grab the data we can use POST request to get JSON from the asmx webservice.

Here is an example of displaying FAQCategory. Note that:
1. UPDATE - updated to knockout 2.1.0 . This will use native templating.
2. Grouping is achieved by creating pivot 'associative' array object :)
3. Notice multiple synchronous request? This is because the webservice is using RetrieveMultiple request (CRM 4.0) thus I need to grab attribute from related entity. Then I append the attributes to my result object. (can use FetchXML but more cumbersome in terms of parsing + slower than QueryExpression. Also, you can use jQuery Ajax function as well if you wish to :))
4. It is displayed using collapsible behavior of jQuery :)


Template:




Hope this helps,

Andreas

Comments

Popular posts from this blog

SharePoint 2013 anonymous access add attachments to list item

Sitecore custom publish agent from specific node and at a specific time

CRM Plugin - Parent and Child Pipeline