Thursday, February 2, 2012

KendoUI : Hiding Columns

Here is a little snippet to hide columns on dataBound event

function HideColumn(gridId,numColumn) {    
    $("#" + gridId +  " th:eq(" + numColumn + ")").hide();
    $("#" + gridId +  " td:nth-child(" + (numColumn+1) + ")").hide();
}

$(document).ready(function () {
     $("#grid").kendoGrid({

        dataBound : function(e) {          
             //RegisterGrid($("#grid").data("kendoGrid"));          
             HideColumn("grid",0);
        },
()

KendoUI : Row Selection

Here is an example which shows how to select a row and saving
a grid instance after creation.
Notice that we register the grid in 'dataBound' event, otherwise
we register an empty grid !!!

var grid;
     
function RegisterGrid(g) {
      grid = g;
      grid.select(grid.tbody.find(">tr").eq(3));         
}

$(document).ready(function () {
    var grid = $("#grid").kendoGrid({

        dataBound : function(e) {          
             RegisterGrid($("#grid").data("kendoGrid"));          
        },
        columns:
            [{
                field: "id",
                title: ""
            
           
            },
                {
                field: "Email",
               title: "Email"
            }],

        dataSource: {
            transport: {
                read: {
                    type: "POST",
                    url: "http://localhost/WebService.asmx/GetAdmin?name=Paul&age=12",
                    data: [],
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true
                }
            },
            schema: {
                data: "d",
                model: {
                    fields: {
                        id: { type: "number" },
                        Email: { type: "string" }
                    }
                },
                total : function (r) {
                   
                }
            },
        },
        selectable: "row",
        navigatable: true,
        sortable: true,
        pageable: true,

        change: function (arg) {          
            var selected = $.map(this.select(), function (item) {
                alert(item.cells[0].innerHTML);                
            });
        },        
    });   
})

Tuesday, January 31, 2012

Object Oriented JavaScript Class Library in C#/.NET Style

(...)Welcome to Object Oriented JavaScript class library in C#/.NET style.(...)

http://www.codeproject.com/Articles/22073/Object-Oriented-JavaScript-Class-Library-in-C-NET

Stanford Javascript Crypto Library

(...)The Stanford Javascript Crypto Library (hosted here on Stanford's server or here on GitHub) is a project by the Stanford Computer Security Lab to build a secure, powerful, fast, small, easy-to-use, cross-browser library for cryptography in Javascript.(...)

http://crypto.stanford.edu/sjcl/

jQuery Selectbox plugin

Very nice plugin.

http://www.bulgaria-web-developers.com/projects/javascript/selectbox/

KendoUI Grid and WebServices

Here is a simple example on how to do :

$(document).ready(function () {
        $("#grid").kendoGrid({
            columns: [
              {
                  field: "id",
                  title: "ID"
              },
              {
                  field: "Email",
                  title: "Email"
              }],

            dataSource: {
                transport: {
                    read: {
                        type : "POST",
                        url  : "http://localhost/WebService.asmx/GetAdmin",
                        data : null,
                        contentType : "application/json; charset=utf-8",
                        dataType: "json",
                        async: true
                    }
                },
                schema : {
                    data: "d"
                }
            }           
        });
    });