Skip to main content

Posts

Showing posts from 2013

knockout js nested foreach

Hello everyone, I'm going to share the code sample for nested foreach in knockout js . Table of Contents.     1.  observableArray  c ollection " selection.selectionItems([])".     2. code sample for view. Step 1 : In this step, we collect the data in observableArray collection i.e. "selection.selectionItems". Step 2 : In the 2nd step,  nested foreach for  selectionItems which are given below.   < div data-bind =" foreach: selection.selectionItems ">     < div data-bind =" foreach: SelectionItems ">                     < h5 data-bind =" text: $data.SelectionLabel "></ h5 >       </ div >  </ div >

knockoutjs observablearray push by conditions

// Here observable array contain three objects. var entries = ko. observableArray ([     { id: '1' , name: "Anil" , age: '28' , type: "A" },     { id: '2' , name: "Kumar" , age: '27' , type: "B" },     { id: '3' , name: "Singh" , age: '29' , type: "C" } ]); var filterdStaus = ko.observable( 'Kushinagar' ); var match = ko.utils.arrayFirst(entries(), function (ech) {             return filterdStaus === ech.Status;     }); if (match) {     entries.push(entry); }

Computed observable in KnockoutJS CSS binding

Here is the code-sample for view code < p data-bind =" text: ClientName , style: { marginLeft: SaveAsDraft ? ‘30px’: ‘0px’} "></ p > If SaveAsDraft is true then icon status images visible margin-left to 30px otherwise visible to 0px. Here is the code-sample for view model code var  viewModel = function (Status) {     var self = this ;     self.Status = Status;     self.ClientName = ko.observable( ‘Anil Singh’ );     self.SaveAsDraft = ko.observable( false );     self.SaveAsDraft = ko.computed( function () {         if (self.Status == ‘ Draft’ ) {             return self.SaveAsDraft( true );                }     }, self); }; ko.applyBindings( new  viewModel());

Knockoutjs computed observable

Table of Contents  code-sample for view. code-sample for view model. Step 1 Here is the code-sample for view code < img class ="status" src ="~/Images/icon_status.png" data-bind =" visible: SaveAsDraft " /> < img class ="status" src ="~/Images/icon_status_red.png" data-bind =" visible: SaveAsError " /> If SaveAsDraft is true then icon status images visible otherwise not visible. If SaveAsError is true then icon status images visible otherwise not visible.  Step 2 Here is the code-sample for view model code var  viewModel = function (Status) {     var self = this ;     self.Status = Status;     self.SaveAsDraft = ko. observable ( false );     self.SaveAsError = ko.observable( false ) ;     self.SaveAsDraft = ko.computed( function () {         if (self.Status == window.itk.model.constant.Draft) {             return window.itk.mytime.viewmodel.

setup sencha touch 2 on windows 7

Hello everyone, I am going to share the basic steps for setup sencha touch in window 7. Right now, I am working on that please follow below links. https://docs.sencha.com/architect/3/getting_started/installation_setup.html https://docs.sencha.com/touch/2.4/getting_started/getting_started.html https://www.sencha.com/forum/showthread.php?245044-Installing-Sencha-Touch-SDK-on-Windows

Ajax JSON cross domain call to REST service

Hello everyone, I'm going to share the code-sample for  Ajax cross domain call to REST service with JSON Request. Keeping in mind, if you working on to call cross domain to REST service. Here server handle two requests each operations.    1. First one for verify the request is OK and return to 200.   2. Send one is revert back the response. You will have to think about the security issues and be careful before doing something like 'Access-Control-Allow-Origin: *' Always return the headers above, not just on OPTION requests. First needs it in the response from the POST. Table of Contents 1. In the step 1, we added the custom headers in the config file. 2. In the step 2, execute the ajax request. Step 1 : In this step, need to add  protocol section from web.config file.   < httpProtocol >    < customHeaders >     < add name = " Access-Control-Allow-Origin " value = " * " />     < add name = " Acce

css hack for safari chrome

Hello everyone,  I’m going to share the code-sample for “ css hack to target ”.  I have an issues to display the log-out popup on-mouse-over on " log-out button" in the different browser (IE, safari and chrome) and we need to fixing using  target specific css. The web-kit browsers are    1. Safari     2. Chrome Table of Contents I have need the target specific CSS for different browsers. CSS class which work on the IE, Firefox. CSS class which “CSS hack to target” Safari and Chrome browser CSS class which ”CSS hack to target” only Safari browser. /*                                  * We hack to Safari and Chrome Webkit-browser targets.  * css hack for chrome and safari. */ Step 1: CSS class which work on the IE, Firefox         .prfl_wrapper         {             position : absolute ;             z-index : 999999 ;             display : block ;             float : left ;             border : 2px solid #ccc ;     

update query in linq to sql

Hi Everyone, I'm going to share the code sample for update query in linq to sql in c# asp.net Today, I have a requirement to update the log details in the DB with respect to the UserId.   /// <summary>   ///  Update to user device access log table using linq to sql in c# .net   /// </summary>   using ( ExceptionLogDataContext dbContext = new ExceptionLogDataContext ())  {                 if (! string .IsNullOrEmpty(UserId))      {                     var IsExistedUser = ( from user in dbContext.UserDeviceAccessLogs               where user.UserId == Convert .ToInt32(UserId)                select user).FirstOrDefault();         if (IsExistedUser.UserId != null )         {                   IsExistedUser.CreatedDate = DateTime .UtcNow;                   IsExistedUser.DeviceType = DeviceType;                   IsExistedUser.LastAccessed = DateTime .UtcNow;                   IsExistedUser.LatestAccessIP = AccessIPAddres

insert query in linq to sql in c#

Hi Everyone, I'm going to share the code sample for insert query in linq to sql in c# asp.net Today, I have a requirement to insert the log details in the DB using asp.net, entity framework and c# as well. /// <summary> /// Insert the user device logs details using to linq to sql with c# .net /// </summary> using ( ExceptionLogDataContext dbContext = new ExceptionLogDataContext ()) {                        if (! string .IsNullOrEmpty(UserId))             {                              // create the table object.                   UserDeviceAccessLog AccessLog = new UserDeviceAccessLog ();                   AccessLog.CreatedDate = DateTime .UtcNow;                   AccessLog.UserId = Convert .ToInt32(UserId);                   AccessLog.ApplicationVersion = "5S.1.0" ;                   AccessLog.AppName = "DempApp" ;                   AccessLog.DeviceId = "iPhone" ;                   AccessLog