Showing posts with label knockout. Show all posts
Showing posts with label knockout. Show all posts

Thursday, June 21, 2018

Working with Knockout Mapping

To work with properties of an object we have to first declare it with its property which can be observable. To work with this, we have to fetch some of the values from service and assign those manually. To overcome this situation we can use Knockout Mapping. If we assign incoming data mapping by knockout mapper it will create observable for each properties which act just like what we have created manually.

To work with knockout mapping, we have to include knockout mapper along with knockout.js 
http://cdnjs.cloudflare.com/ajax/libs/knockout.mapping/2.3.5/knockout.mapping.js

To create new variable use "var MyData = ko.mapping.fromJS(serviceData)"
In above statement, "serviceData" is data from service which will be mapped with "ko.observable" to "MyData".

Knockout Mapping


Thursday, May 7, 2015

Working with Export to PDF in Kendo Grid

Here is some link to work with export to PDF in kendo grid

(A) PDF Export Demo: Export to PDF demo and documentation link 
(1) Grid / Export to PDF

(2) Walkthrough of the Grid Features and Behavior

(B) Kendo UI Export Options with Customizations: Export to PDF functionality in two different way you want to manipulate
(1) Kendo UI Drawing API Export functionality - Document Export

(2) Kendo UI PDF Export customizations - Page Layout

(C) Kendo Grid Export to PDF: Export to PDF with launcher which lets user to ask user if we export then it will ask user with open/save dialog
(1) Kendo UI Grid Export to Excel / PDF not working on IE9

(2) Kendo Grid Configuration for Export

Saturday, December 6, 2014

Durandal JS Work Arounds

Here is some work around while working with durandal framework
(A) Call function from another file
Follow the steps to use script file
- put your file name in define tag of js file where you want to use it
- put alias for that file in same file as an argument in function
- now you can use that file using its alias in your application

(B) To provide width for message box
Follow the steps to provide width in message box
- assuming like you have your app declared over the top of the viewmodel in following way
var app = require('durandal/app');
- app.showMessage("message", 'Warning', [{ text: "Yes", value: "Yes" }, { text: "No", value: "No" },true, { style: { width: "400px" } })

(C) To pass multiple argument for modal dialog
- assuming like you have your app declared over the top of the viewmodel in following way
var app = require('durandal/app');
- call showDialog to open view in dialog
app.showDialog('dialog view', "param1Value").then(function () {});
app.showDialog('dialog view', {param1,"param1value", param2,"param2value"}).then(function () {});
- how to access value
for single value, it will be like 
vm.activate = function (param1) { //param1 will be placed anywhere it requires}
for multiple value,
vm.activate = function (params) { //params.param1 for first parameter value and same for other parameter like //params.param2 and it will replace with value for param1 & param2 with param1value & param2value respectively}

(D) message box with multiple buttons, 
- assuming like you have your app declared over the top of the viewmodel in following way
var app = require('durandal/app');
- put your code like below and it will show up with three buttons Button1, Button2 & Button3 and on clicking of any button respective code block will be called
app.showMessage("Message", 'MessageType', [{ text: "Button1", value: "Button1" }, { text: "Button2", value: "Button2" }, { text: "Button3", value: "Button3" }]).done(function (result) {
if (result === 'Button1') {//Code for button1}
else if (result === 'Button2') {//Code for button2}
else if (result === 'Button3') {//Code for button3}
});

(E) Compose view
- to show only view you can directly do like following way

- to load your view model with your view for some processing you can put like following way

In above case, it will load html and associate js file for that view.

(F) Working with view
- to work or bind any event for any control in view, you can bind it in "attached" event because in "activate" event it will be load your full view to "DOM" and in "attached" event you can play with it.

(G) Navigation process
- If you want to cancel navigation or need to process some logic while user navigate away from existing location you can put your logic to "canDeactivate" event.
- In this event, you can process your logic and based on that you can cancel navigation for user

Saturday, November 29, 2014

Working with Durandal

Here is some links for Durandal framework.
(A) Durandal: Durandal is small JavaScript framework designed to make building Single Page Applications (SPAs) simple and elegant. 

(1) Durandal

(2) Docs | Durandal

(3) Docs - Introduction | Durandal

(4) Docs - Durandal's Edge | Durandal

(5) Durandal Get Started

(6) Docs - Manual Setup | Manual Setup

(7) Hello Workd | Durandal Sample

(8) Durandal with ASP.NET MVC Conventions

(9) Building a SPA with Durandal, Knockout and Breeze

(10) Rich Data Management in JavaScript

(B) Require JS: RequireJS is a JavaScript file and module loader. 
(1) Require JS

(2) Why AMD?

(3) WHY WEB MODULES?

(C) AMD: The Asynchronous Module Definition (AMD) API specifies a mechanism for defining modules such that the module and its dependencies can be asynchronously loaded.
(1) AMD & AMD1

(2) AMD Tests

(3) AMD Implement

Monday, August 4, 2014

Error : Service data not get refresh in IE8 from Client Side

I face problem of Data not refresh from client side when we are working with IE. I found this problem while i am working with IE8 and above.

Problem is like, in my MVC Single Page Application, when we are fetching any data from client side for first time it will get data perfectly but subsequent call for same data or some back and forth to some other location give me previous unchanged data which are cached. But, after a bit of googling following line of code works for me and resolved my problem.



This line of code i put in "_layout.cshtml" header section and it works for me and then after it gives me refreshed data view.


The above line of code works fine for me and resolved my problem.

Tuesday, March 11, 2014

Working with Conditional Comments

Here are some links about Conditional Statements.

Conditional comments are statements interpreted by Microsoft Internet Explorer in HTML source code. Conditional comments can be used to provide and hide code to and from Internet Explorer.

(1) About conditional comments

(2) Conditional comments

(3) Conditional comment

(4) Conditional comments of IE