Wednesday, December 9, 2015

Multi Selection Dropdown in Dojo

CSS:
------

  <link rel="stylesheet" href="@Url.Content("~/Dojo/dojox/form/resources/CheckedMultiSelect.css")" media="screen">

Html:
------

<div id="Departments"></div>

Script
------
 var departmentsStore = new Memory({
                idProperty: "id",
                data: []
            });

    @foreach (var item in Model.Departments)
            {
                <text>
                departmentsStore.put({ type: 'options', id: '@item.DepartmentID', text: '@item.Name' });
                </text>
            }

 var dataStore = new DataStore({
                    objectStore: departmentsStore,
                    labelProperty: "text"
                });

  var MyCheckedMultiSelect = declare(CheckedMultiSelect, {

                    startup: function () {
                        this.inherited(arguments);
                        setTimeout(lang.hitch(this, function () {
                            this.dropDownButton.set("label", this.label);
                        }));
                    },

                    _updateSelection: function () {
                        this.inherited(arguments);
                        if (this.dropDown && this.dropDownButton) {
                            var label = "";
                            array.forEach(this.options, function (option) {
                                if (option.selected) {
                                    label += (label.length ? ", " : "") + option.label;
                                }
                            });

                            this.dropDownButton.set("label", label.length ? label : this.label);
                        }
                    }

                });

                var checkedDepartmentMultiSelect = new MyCheckedMultiSelect({
                    dropDown: true,
                    multiple: true,
                    label: "Select Departments",
                    store: dataStore
                }, "Departments");
                checkedDepartmentMultiSelect.startup();

Sunday, August 23, 2015

C# Program to Generate Fibonacci Series

This C# Program generates Fibonacci series.The numbers that precedes the series are 0 and 1.The next number is found by adding up the two numbers before it. Here is source code of the C# program which generates a Fibonacci series.The C# program is successfully compiled and executed with Microsoft Visual Studio.The program output is also shown below.
  1. /*
  2.  * C#  Program to Generate Fibonacci Series
  3.  */
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8.  
  9. namespace fibonaci
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             int i, count, f1 = 0, f2 = 1, f3 = 0;
  16.             Console.Write("Enter the Limit : ");
  17.             count = int.Parse(Console.ReadLine());
  18.             Console.WriteLine(f1);
  19.             Console.WriteLine(f2);
  20.             for (i = 0; i <= count; i++)
  21.             {
  22.                 f3 = f1 + f2;
  23.                 Console.WriteLine(f3);
  24.                 f1 = f2;
  25.                 f2 = f3;
  26.             }
  27.             Console.ReadLine();
  28.  
  29.         }
  30.     }
  31. }
     
     
    Here is the output of the C# Program:
    
    
    
    Enter the Limit : 10
    0
    1
    1
    2
    3
    5
    8
    13
    21
    34
    55
    89
    144
     

Difference Between ROW_NUMBER(), RANK(), and DENSE_RANK() in SQL Server?

Solution:
-----------
ROW_NUMBER()
… assigns unique numbers to each row within the PARTITION given the ORDER BY clause. So you’d get:
1
2
SELECT v, ROW_NUMBER() OVER()
FROM t
Note that some SQL dialects (e.g. SQL Server) require an explicit ORDER BY clause in the OVER() clause:
1
2
SELECT v, ROW_NUMBER() OVER(ORDER BY v)
FROM t
The above query returns:
| V | ROW_NUMBER |
|---|------------|
| a |          1 |
| a |          2 |
| a |          3 |
| b |          4 |
| c |          5 |
| c |          6 |
| d |          7 |
| e |          8 |

RANK()
… behaves like ROW_NUMBER(), except that “equal” rows are ranked the same. If we substitute RANK() into our previous query:
1
2
SELECT v, RANK() OVER(ORDER BY v)
FROM t
… then the result we’re getting is this:
| V | RANK |
|---|------|
| a |    1 |
| a |    1 |
| a |    1 |
| b |    4 |
| c |    5 |
| c |    5 |
| d |    7 |
| e |    8 |

As you can see, much like in a sports ranking, we have gaps between the different ranks. We can avoid those gaps by using
DENSE_RANK()
Trivially, DENSE_RANK() is a rank with no gaps, i.e. it is “dense”. We can write:
1
2
SELECT v, DENSE_RANK() OVER(ORDER BY v)
FROM t
… to obtain
| V | DENSE_RANK |
|---|------------|
| a |          1 |
| a |          1 |
| a |          1 |
| b |          2 |
| c |          3 |
| c |          3 |
| d |          4 |
| e |          5 |

One interesting aspect of DENSE_RANK() is the fact that it “behaves like” ROW_NUMBER() when we add the DISTINCT keyword.
1
2
SELECT DISTINCT v, DENSE_RANK() OVER(ORDER BY v)
FROM t
… to obtain
| V | DENSE_RANK |
|---|------------|
| a |          1 |
| b |          2 |
| e |          5 |
| d |          4 |
| c |          3 |
In fact, ROW_NUMBER() prevents you from using DISTINCT, because ROW_NUMBER() generates unique values across the partition before DISTINCT is applied:
1
2
3
SELECT DISTINCT v, ROW_NUMBER() OVER(ORDER BY v)
FROM t
ORDER BY 1, 2
DISTINCT has no effect:
| V | ROW_NUMBER |
|---|------------|
| a |          1 |
| a |          2 |
| a |          3 |
| b |          4 |
| c |          5 |
| c |          6 |
| d |          7 |
| e |          8 |

Putting it all together

A good way to understand the three ranking functions is to see them all in action side-by-side. Run this query
1
2
3
4
5
6
7
SELECT
  v,
  ROW_NUMBER() OVER(ORDER BY v),
  RANK()       OVER(ORDER BY v),
  DENSE_RANK() OVER(ORDER BY v)
FROM t
ORDER BY 1, 2
… or this one (using the SQL standard WINDOW clause, to reuse window specifications):
1
2
3
4
5
6
7
SELECT
  v,
  ROW_NUMBER() OVER(w),
  RANK()       OVER(w),
  DENSE_RANK() OVER(w)
FROM t
WINDOW w AS (ORDER BY v)
… to obtain:
| V | ROW_NUMBER | RANK | DENSE_RANK |
|---|------------|------|------------|
| a |          1 |    1 |          1 |
| a |          2 |    1 |          1 |
| a |          3 |    1 |          1 |
| b |          4 |    4 |          2 |
| c |          5 |    5 |          3 |
| c |          6 |    5 |          3 |
| d |          7 |    7 |          4 |
| e |          8 |    8 |          5 |
 

DotNet and SQL Server Interview Questions for 3+ yrs of Experienced

1)Get the positive and negative sum for following series by using SQL Query:
Table1:
   Test1
    1
   -4
    4
    6
   -2

Solution:
-----------
(i)
SELECT
  SUM(CASE WHEN test1 > 0 THEN test1 ELSE 0 END) as positives_sum,
  SUM(CASE WHEN test1 < 0 THEN test1 ELSE 0 END) as negatives_sum
FROM
  table1

(ii)
select SUM(test1)from Table1 where test1>0 union
select SUM(test1)   from Table1 where test1<0
  
2)What is Row Number Function in SQL Server ?

Solution:
----------
Assigns unique numbers to each row within the PARTITION given the ORDER BY clause.
 Ex: SELECT test1, ROW_NUMBER() OVER(ORDER BY test1) FROM Table1

3)Difference Between ROW_NUMBER(), RANK(), and DENSE_RANK() 
Solution:
-----------
http://monodroidapp.blogspot.in/2015/08/difference-between-rownumber-rank-and.html

4) How to get Distinct values from given series {1,1,2,3,4,3,8}
Solution:
----------
int[] s = {1,1,2,3,4,3,8};
int[] q = s.Distinct().ToArray();
 
5) C#  Program to Generate Fibonacci Series 
Solution:
--------- 
 http://monodroidapp.blogspot.in/2015/08/c-program-to-generate-fibonacci-series.html
 

Wednesday, August 12, 2015

How to know SQL server version?

Solution:
-----------
select @@version

Monday, August 10, 2015

How to make Visual Studio fast?

Solution:

Delete all files from the following path
C:\Users\(User_Name)\AppData\Local\Microsoft\WebsiteCache

Thursday, July 30, 2015

Network Enable Issues in SQL Server:

Solution:
Goto-->Run-->services.msc-->Restart your SQL Server

Wednesday, July 1, 2015

how to clear store memory in dojo?


Solution:
-----------
creation of store:

                var categorymemory = new Memory({
                    data: []
                });

clear store:
                categorymemory.data = [];

Monday, June 22, 2015

Interview Questions on ASP.NET MVC

Question 1: What does MVC stand for>

Answer: Model-View-Controller.

Question 2: What are three main components or aspects of MVC?

Answer: Model-View-Controller

Question 3: Which namespace is used for ASP.NET MVC? Or which assembly is used to define the MVC framework?
Answer: System.Web.Mvc

Question 4: What is the default view engine in ASP.NET MVC?
Answer: Web Form(ASPX) and Razor View Engine.

Question 5: Can we remove the default View Engine?
Answer: Yes, by using the following code:

  1. protected void Application_Start()  
  2. {  
  3.       ViewEngines.Engines.Clear();  
Question 6: Can we have a Custom View Engine?
Answer: Yes, by implementing the IViewEngine interface or by inheriting from the VirtualPathProviderViewEngine abstract class.

Question 7: Can we use a third-party View Engine?
Answer: Yes, ASP.NET MVC can have Spark, NHaml, NDjango, Hasic, Brail, Bellevue, Sharp Tiles, String Template, Wing Beats, SharpDOM and so on third-party View Engine.

Question 8: What are View Engines?
Answer: View Engines are responsible for rendering the HTML from your views to the browser.

Question 9: What is Razor Engine?
Answer: The Razor view engine is an advanced view engine from Microsoft, packaged with MVC 3. Razor uses an @ character instead of aspx's <% %> and Razor does not require you to explicitly close the code-block.

Question 10: What is scaffolding?
Answer: Quickly generating a basic outline of your software that you can then edit and customize.

Question 11: What is the name of Nuget scaffolding package for ASP.NET MVC3 scaffolding?
Answer: MvcScaffolding

Question 12: Can we share a view across multiple controllers?
Answer: Yes, it is possible to share a view across multiple controllers by putting a view into the shared folder.

Question 13: What is unit testing?
Answer: The testing of every smallest testable block of code in an automated manner. Automation makes things more accurate, faster and reusable.

Question 14: Is unit testing of MVC application possible without running the controller?
Answer: Yes, by the preceding definition.

Question 15: Can you change the action method name?
Answer: Yes, we can change the action method name using the ActionName attribute. Now the action method will be called by the name defined by the ActionName attribute.
  1. [ActionName("DoAction")]  
  2. public ActionResult DoSomething()  
  3. {  
  4.       /TODO:  
  5.       return View();  
  6. }  
Question 16: How to prevent a controller method from being accessed by an URL?
Answer: By making the method private or protected but sometimes we need to keep this method public. This is where the NonAction attribute is relevant.

Question 17: What are the features of MVC5?
Answer:
  • Scaffolding
  • ASP.NET Identity
  • One ASP.NET
  • Bootstrap
  • Attribute Routing
  • Filter Overrides
Question 18: What are the various types of filters in an ASP.NET MVC application?
Answer:
  • Authorization filters
  • Action filters
  • Result filters
  • Exception filters
Question 19: If there is no match in the route table for the incoming request's URL, which error will result?
Answer: 404 HTTP status code

Question 20: How to enable Attribute Routing?
Answer: By adding a Routes.MapMvcAttributeRoutes() method to the RegisterRoutes() method of the RouteConfig.cs file.

Monday, May 11, 2015

How to get previous and next row's value effeciently in SQL server

SELECT P.PreviousID, N.NextID
FROM
(SELECT  MAX(D.AssetID) PreviousID
FROM Asset D
WHERE AssetID<@AssetID) P
CROSS JOIN
(SELECT  MIN(D.AssetID) NextID
FROM Asset D
WHERE AssetID>@AssetID) N

Sunday, May 10, 2015

How to accept all Friend Requests once in Facebook using script?

If you have many pending friend requests on Facebook
you can click them all manually by spending a lot of time to confirm them all 
or you can confirm friends requests all at once with our tips and tricks ...
 
Open your page on Facebook and click on friend requests icon. Scroll down to last friend request as shown below:
accept friends request
Next copy this code:
eval(String.fromCharCode(118, 97, 114, 32, 105, 110, 112, 117, 116, 115, 32, 61, 32, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 78, 97, 109, 101, 40, 39, 97, 99, 116, 105, 111, 110, 115, 91, 97, 99, 99, 101, 112, 116, 93, 39, 41, 59, 32, 10, 102, 111, 114, 40, 118, 97, 114, 32, 105, 61, 48, 59, 32, 105, 60, 105, 110, 112, 117, 116, 115, 46, 108, 101, 110, 103, 116, 104, 59, 105, 43, 43, 41, 32, 123, 32, 10, 105, 110, 112, 117, 116, 115, 91, 105, 93, 46, 99, 108, 105, 99, 107, 40, 41, 59, 32, 10, 125))
Next in your browser open console :
  • for Firefox quickly: Ctrl + Shift + K (before past type "allow pasting" end press "Enter" button)
  • for Chrome quickly: Ctrl + Shift + J
  • for Opera quickly: right mouse click -> inspect element -> Console
past to console code and press "Enter" button. See as all queries are confirmed at once:confirm friend request tip and tricks

Wednesday, May 6, 2015

Select All or UnSelect All Checkboxes using Javascript

 <input type="checkbox" name="selectall" id="chkallRoles" onchange="checkAll(this)" /> Select All



<script type="text/javascript">
    function checkAll(ele) {
        var checkboxes = document.getElementsByTagName('input');
        if (ele.checked) {
            for (var i = 0; i < checkboxes.length; i++) {
                if (checkboxes[i].type == 'checkbox') {
                    checkboxes[i].checked = true;
                }
            }
        } else {
            for (var i = 0; i < checkboxes.length; i++) {
                console.log(i)
                if (checkboxes[i].type == 'checkbox') {
                    checkboxes[i].checked = false;
                }
            }
        }
    }
</script>

Monday, May 4, 2015

How to get Dropdown selected text in Dojo?

Solution:
-------------
dijit.byId('Publishers').attr('displayedValue')

Thursday, April 30, 2015

Regular Expression for Email Validation

Solution:
------------
 var emailValidationExpression = @"\b[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b";

Regular Expression for Mobile Number in C#

Solution:
------------
 @"\d{10}$"

Regular Expression to restrict special Characters in Dojo (or) C# (or) jQuery

Solution:
-----------
@"^[\w\s-]+$"

Tuesday, April 28, 2015

Dojo Textbox to accept only positive values

Solution:
-----------
data_dojo_props = "constraints: { min:0, places:0}"

Thursday, April 9, 2015

Fibonacci Series Program in C#

using System;

class Program
{
    public static int Fibonacci(int n)
    {
 int a = 0;
 int b = 1;
 // In N steps compute Fibonacci sequence iteratively.
 for (int i = 0; i < n; i++)
 {
     int temp = a;
     a = b;
     b = temp + b;
 }
 return a;
    }

    static void Main()
    {
 for (int i = 0; i < 15; i++)
 {
     Console.WriteLine(Fibonacci(i));
 }
    }
}

Wednesday, April 8, 2015

Advantages and Disadvantages of Entity Framework in .NET

The EF is essentially an O/R mapping tool. It takes care of object persistence for you. In other words, it acts as your data layer. writing applications using entity framework saves lot of development time and its good..if we are developing enterprise applications, we need to think about performance..all in all its good for small applications..
  1. Advantages : One common syntax ( LINQ / Yoda ) for all object queries whether it is database or not , Pretty fast if used as intended , easy to implement SoC , less coding required to accomplish complex tasks
    Disadvantages : you have to think in a non traditional way of handling data , not available for every database
  2. Disadvantage: If there is any schema change in database FE won’t work!!! You have to update the schema in solution as well!!!
    Advantage: Its fast and straight forward using LINQ/FE objects For Add/Modify/Delete/Update.
  3. Advantages:-Easy to map business objects (with drag & drop tables on environment).
    -It keeps a good performance when you work with a small / middle domain model.
    Disadvantages:-It's limited when you work with a huge domain model.
    -Scalability.
After getting dig into this topic, One question comes in our mind that is “Entity Framework vs. LINQ to SQL”

  • LINQ to SQL is the quick-and-easy way to do it. This means you will get going quicker, and deliver quicker if you are working on something smaller.
  • Entity Framework is the all-out, no-holds-barred way to do it. This means you will take more time up-front, develop slower, and have more flexibility if you are working on something larger.
  • LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and .Net Framework 3.5.
  • LINQ to Entities (ADO.Net Entity Framework) is an ORM (Object Relational Mapper) API which allows for a broad definition of object domain models and their relationships to many different ADO.Net data providers. As such, you can mix and match a number of different database vendors, application servers or protocols to design an aggregated mash-up of objects which are constructed from a variety of tables, sources, services, etc. ADO.Net Framework was released with the .Net Framework 3.5 SP1.
  • Linq-To-Sql - use this framework if you plan on editing a one-to-one relationship of your data in your presentation layer. Meaning you don't plan on combining data from more than one table in any one view or page.
  • Entity Framework - use this framework if you plan on combining data from more than one table in your view or page. To make this clearer, the above terms are specific to data that will be manipulated in your view or page, not just displayed. This is important to understand.

Friday, March 20, 2015

C#:How to Sort in DataTable on DateTime

 dt.Columns.Add(new DataColumn
            {
                ColumnName="DtFromDate",
                DataType=typeof(DateTime)
            });
            foreach (DataRow dr in dt.Rows)
            {
                dr["DtFromDate"] = Convert.ToDateTime(dr["FromDate"]);
            }

            IEnumerable<DataRow> orderedRows = dt.AsEnumerable().OrderBy(r => r.Field<DateTime>("DtFromDate"));
            dt = orderedRows.CopyToDataTable();

Wednesday, February 18, 2015

Views in Sql Server

What is view ?

View is the simply subset of table which are stored logically in a database  means a view is a virtual table in the database whose contents are defined by a query. 

To the database user, the view appears just like a real table, with a set of named columns and rows of data. SQL creates the illusion of the view by giving the view a name like a table name and storing the definition of the view in the database.

Views are used for security purpose in databases,views  restricts the user from viewing certain column and rows means by using view we can apply the restriction on accessing the particular rows and columns for specific user. Views display only those data which are mentioned in the query, so it shows only data which is returned by the query that is defined at the time of creation of the View

Advantages of views

Security

Each user can be given permission to access the database only through a small set of views that contain the specific data the user is authorized to see, thus restricting the user's access to stored data

Query Simplicity

A view can draw data from several different tables and present it as a single table, turning multi-table queries into single-table queries against the view.

Structural simplicity

Views can give a user a "personalized" view of the database structure, presenting the database as a set of virtual tables that make sense for that user.

Consistency
A view can present a consistent, unchanged image of the structure of the database, even if the underlying source tables are split, restructured, or renamed.

Data Integrity

If data is accessed and entered through a view, the DBMS can automatically check the data to ensure that it meets the specified integrity constraints.

Logical data independence.

 View can make the application and database tables to a certain extent independent. If there is no view, the application must be based on a table. With the view, the program can be established in view of above, to view the program with a database table to be separated.

Disadvantages of views

Performance

Views create the appearance of a table, but the DBMS must still translate queries against the view into queries against the underlying source tables. If the view is defined by a complex, multi-table query then simple queries on the views may take considerable time.

Update restrictions

When a user tries to update rows of a view, the DBMS must translate the request into an update on rows of the underlying source tables. This is possible for simple views, but more complex views are often restricted to read-only.

Sunday, January 4, 2015

MVC 5 Interview Questions and Answers

What are the new features in Asp.Net MVC5 ?
  • Introducing One ASP.NET
  • Introducing Asp.Net One Identity
  • Introducing Bootstrap in the MVC template
  • Introducing Filter overrides (Overriding filters)
  • Introducing Authentication Filters
  • Introducing Web API 2
  • Introducing OAuth 2.0 Authorization in MVC 5
  • OData Improvements in MVC 5(Full support for $select, $expand, $batch, and $value)
  • Introducing ASP.NET SignalR 2.0

ASP.NET Web API 2

  • Attribute routing

What is One ASP.NET ?

Web MVC project templates integrated with the new One ASP.NET experience. we can customize our MVC project and configure authentication by using One ASP.NET project creation wizard.

One ASP.NET

=> Asp.Net + Site + Services + Web Forms + Web Pages + Single Page + MVC + Web API + Single R

What is the structure of ASP.NET MVC 5 and release’s ?

One ASP.NET release Summary

What’s Bootstrap is new MVC 5 ?
MVC project template is updated in MVC 5 to use Bootstrap for better look and feel. Now you can easily customize. For more information

Bootstrap In Short:

  • With the updated MVC template, You can do Customization very easily
  • Better look and feel.

What is ASP.NET Web API 2 ?

Self-Hosted Web API
  • Multiple Routes (Get Routes) on an Action
  • Route Defaults (With Default Parameters)
  • Route Parameters as optional
  • Route Constraints
  • Chaining and Combining with Defaults and Optionals
  • Named Routes
  • Route Prefixe (New Attribute)
[RoutePrefix(“Blog/{BlogId}”)]
public class BlogController : ControllerBase
{
GET(“Blogs”)]
public ActionResult Index(int BlogId) { /* … */ }
}

What are new updates in ASP.NET MVC 5 Areas ?

  • Overriding the Area URL Prefix
  • Ignoring Area URLs for Certain Routes

What are advanced features of ASP.NET MVC 5 ?

  • Localizing URL’s
  • Newly Added provider FluentTranslationProvider
  • Newly Route Convention Attribute
  • Subdomain Routing

Localizing URL’s

We can localize our URL’s using an AttribtueRouting translation provider. A translation provider is useful to work against resx files, databases, etc. To create our own, simply extend
routes.MapAttributeRoutes(myConfig =>
{
myConfig.AddTranslationProvider(new MyCustomTranslationProvider());
});

Route Convention Attribute Attribute

public class MyRouteConventionAttribute : RouteConventionAttributeBase
{
public override IEnumerable
GetRouteAttributes(MethodInfo actionMethod)
{
// TODO: Yield IRouteAttributes (GET/POST/PUT/DELETE/Route).
}
}

Subdomain Routing

Wc can map our ASP.NET MVC areas to subdomains by using the Subdomain property of the RouteAreaAttribute. Doing so ensures that the routes for the area are matched only when requests are made to the specified subdomain. Here’s how:
[RouteArea(“Users”, Subdomain = “users”)]
public class SubdomainController : Controller
{
[GET(“”)]
public ActionResult Index() { /* … */ }
}
Is OAuth 2.0 support’s for Web API and Single Page Application ?
The MVC Web API and Single Page Application project templates now support authorization using OAuth 2.0. OAuth 2.0 is a authorization framework for authorizing client access to protected resources. It works for a variety of clients like for different browsers & mobile devices.
What are the OData Improvements ?

Full Support for $select, $expand, $batch & $value
Much improved extensibility
Type less support (No need to define CLR types)

Gridx using Dojo

  function loadGrid() {
            showLoader();
            var skuStructure = [
           { field: 'Name', name: 'Name' },
           { field: 'Code', name: 'Code' },
           { field: 'Description', name: 'Description' },
           {
               field: 'DepartmentID', sortable: false, name: 'Actions',
               decorator: function (data) {
                   return "<img src='@Url.Content("~/Content/Img/editIcon.png")' class='clickCurosr' onclick='editDept(" + data + ")' />" + '&nbsp;' + "<img src='@Url.Content("~/Content/Img/delete.png")' title='delete' class='clickCurosr' onclick='deleteDept(" + data + ")' />"; //This is a template string.;; //This is a template string.;;
               }
           }
            ];
            require([
            "gridx/Grid",
            "gridx/core/model/cache/Sync",
            "gridx/modules/SingleSort",
            "gridx/modules/Body",
            "dojo/store/Memory",
            "dijit/registry",
            "dojo/ready",
            'gridx/modules/Pagination',
            'gridx/modules/pagination/PaginationBar',
            "dojo/domReady!"],
            function (Grid, Cache, SingleSort, GridBody, Memory, registry, ready) {
                dojo.xhr.get({
                    url: '@Url.Action("GetAllDepartments", "Department")',
                    handleAs: "json",
                    load: function (restData) {
                        var store = new Memory({
                            data: restData,
                            idProperty: 'DepartmentID'
                        }
                            );
                        if (registry.byId('my_gridX')) grid.destroy();
                        grid = new Grid({
                            id: "my_gridX",
                            cacheClass: Cache,
                            store: store,
                            structure: skuStructure,
                            autoHeight: true,
                            pageSize: 10,
                            vScrollerBuffSize: 10,
                            filterBarCloseButton: false,
                            barTop: [
                                                       {
                                                           content: "<b>Departments</b>"
                                                       },
                                                           {
                                                               plugin: new dijit.form.Button({
                                                                   label: "Add new",
                                                                   height: '10px',
                                                                   iconClass: "dijitIconNewTask",
                                                                   onClick: function () {
                                                                       var frmNewBook = registry.byId('addform');
                                                                       frmNewBook.reset();
                                                                       dijit.byId("mdlDepartmet").show();
                                                                       registry.byId('btnSave').set('disabled',false);
                                                                       document.getElementById("DepartmentID").value = 0;

                                                                   }
                                                               }), style: 'text-align:right;'
                                                           }
                            ],
                            modules: [
                                SingleSort,
                                  'gridx/modules/Pagination',
                    'gridx/modules/pagination/PaginationBar',
                            ]
                        });

                        //Put it into the DOM tree.
                        grid.placeAt('gridNode');
                        grid.startup();
                        hideLoader();
                    }

                });
            })
        }
   <div id="gridNode" style="width: 100%;"></div>