Skip to main content

Posts

Showing posts from February, 2014

What is IndexOf in KnockoutJs Array?

arrayIndexOf Using ArrayIndexOf , find the matched items from array collection. If array items are matched then returns true otherwise returns false. For Example filter an observable array collection using indexOf() .   var filterAnArrayByArrayIndexOf = function (Text) {            try {                var filterText = Text.toLowerCase();                         if (!filterText) {                    return selectionList();                }                else {                    if (selectionList().length > 0) {                        return ko.utils.arrayFilter(selectionList(), function (item) {                            if (item.SelectionLabel.toLowerCase().indexOf(filterText) > -1 || item.SelectionDescription.toLowerCase().indexOf(filterText) > -1) {                                 return true ;                            }                            else {                               return false ;                  

knockout js arrayPushAll

arrayPushAll This is basically use for push the old array collection in the  new array collection by using the ko.utils.arrayPush() For example  newArrayListItems () is a new array list and  oldArrayItems () array list. ko.utils.arrayPushAll(newArrayListItems(), oldArrayItems);

Knockout js Array First

arrayFirst Array firstly returns only first items which are matched. For Example    var findSelectedCodeSetFromLabel = function (label, codeSet) {           try {                   if (codeSet != null && codeSet.length > 0) {                      return ko.utils.arrayFirst(codeSet, function (item) {                           return (item.Label.toLowerCase().indexOf(label.toLowerCase()) > -1);                      });                  };           }            catch (ex) {                logExceptions(ex);           }   };

Knockout js Filter an observable Array

arrayFilter Array filter is availing an observable-array and returns true if array of items are match otherwise returns false.  For example filter an observable array using computed binding  as given below. var filterSelections = ko.computed(function (Text) { try { var filterText = Text.toLowerCase(); if (!filterText) { return selectionList(); } else { if (selectionList().length > 0) { return ko.utils.arrayFilter(selectionList(), function (item) { if (item.SelectionLabel.toLowerCase().indexOf(filterText) > -1 || item.SelectionDescription.toLowerCase().indexOf(filterText) > -1) { return true; } else { return false; } });

Delegate in c# with simple example

Delegate in C# Delegate is an object which holds the references to a method within delegate object. Delegate is a type-safe object. Delegate is invoke to methods in asynchronously manner. Delegate encapsulates a static methods or instance methods instance. Delegate can be with parameters or without parameters. Most importent use of delegate: 1. Improve the performance of application. 2. Encapsulat to methods call from caller. 3. Call a method asynchronously. Three steps for using delegates: 1. Declare 2. Create 3. Point Delegate are Two types: 1. Delegate 2. Multicast Delegate Generic readymade delegate are : 1. Func < input, output > 2. Action < inputParameter > 3. Predicate < inputParameter > Delegate is use when we needed to pass the single reference to a method within delegate object. Multicast Delegate is use when we needed to pass the nore then one reference to a method within delegate object.

How knockoutJs different from MVC?

1.        KnockoutJs is a MVVM pattern. 2.        MVC is a design pattern. 3.        Knockoutjs work like connected mode. 4.        MVC work like disconnected mode. 5.        Knockoutjs supported two types of binding a.        One-way binding b.        Two-way binding 6.        MVC supported only one-way binding. 7.        In Knockoutjs, UI part automatically update when your data model update. 8.        In MVC, not update UI automatically when your data model update. Need event to call data model and update it. 9.        In MVC, model part directly binds with the view page. 10.    In KnockoutJs, model part is not directly bind with the view page. Model directly binds with the view-model and view-model directly with the view page.

Abbreviation of a string in JavaScript using a Regular Expressions

Table of Contents HTML View for Description textarea JavaScript methods and call onkeyup  For example, when we type ccc and press the space key that time [ccc =>  conference call with customer].  here the value of ccc is predefined the array list.  < textarea id ="txtDescription" onkeyup ="return checkAbbreviationKey(event)" ></ textarea > JavaScript methods and call onkeyup   function checkAbbreviationKey(evt) {      var charCode = (evt.which) ? evt.which : event.keyCode         if (charCode == 32) {                       var charStr = evt.target.value.match( /\S+/g )             var abbreviations = isAbbreviations();                              if (abbreviations.length > 0) {                 for ( var index in abbreviations) {                     var reg = new RegExp( "\\b" + abbreviations[index].Anchor + "\\b" , "g" );                     if (charStr[charS