Thursday, May 29, 2014

MVC KENDO GRID WORKING

MVC Kendo Grid Example

1St Method

First Go to Master Page.


And add the following line of Code. Now when I click on Employee the Details should be displayed to me.


Now I need to create an Employee Controller.Before That I would like to

1 Create a Folder with View Models.
 2 create a class with name “EmployeeViewModel” to add gets and sets properties.



Go to EmployeeViewModel.cs and write the following lines of Code.
public class EmployeeViewModel
    {
public int Employeeno { get; set; }
       public string EmployeeName { get; set; }
       public string EmployeeAddress { get; set; }       
public List<EmployeeViewModel> lstEmployees { get; set; }
     }

Add the Reference of Kendo

And then go to Web.Config  and add namespace for Kendo ( in both the web.config files)

1 which is inside View Folder
2 which is outside



To Apply Styles
Go to Content Folder, all the styles related to Kendo need to be paste here.



All the scripts files related to Kendo need to be in Scripts Folder



Then go to master page (layout.cs.html) under View Folder and add the following styles and js files related to Kendo.


Then go to controller folder , and select



And Click On Add button.



Write the following Method in Employee Controller as shown above.

Create a Model Class with Name Employee.cs and write the following code as shown.



So go to Controller and Right click on Selected Method Name i.e. (Employee Details)




And Click on Add Button.
Write the following code
@model MvcApplication3.ViewModels.EmployeeViewModel
@{
    ViewBag.Title = "EmployeeDetails";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>EmployeeDetails</h2>

@(Html.Kendo().Grid(Model.lstEmployees)
        .Name("grdReports")
        .Columns(columns =>
        {
            columns.Bound(c => c.Employeeno).Width(140);
            columns.Bound(c => c.EmployeeName).Width(90);
            columns.Bound(c => c.EmployeeAddress).Width(90);
        })

       // .BindTo(Model.GetReportDetails())
        .Sortable()
         .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(false)
            .ButtonCount(2))
            .DataSource(dataSource => dataSource
                .Ajax()
                 .PageSize(5)
                .ServerOperation(false)
        )
    )

And Run the application



Click on Employee Tab


JAVASCRIPT BASIC EXAMPLES FOR BEGINNERS(Performing Add, Sub, Multiply,Divide.)

Performing Add, Sub, Multiply,Divide.

<HEAD><CENTER> </center></HEAD>
    <SCRIPT LANGUAGE="JAVASCRIPT">
      function fadd_click()
      {
accept();
document.f1.c.value=eval(x)+eval(y);
      }
      function fdiff_click()
      {
accept();
document.f1.c.value=eval(x)-eval(y);
      }
      function fmult_click()
      {
accept();
document.f1.c.value=eval(x)*eval(y);
      }      
      function fQuo()
      {
accept();
document.f1.c.value=eval(x)/eval(y);
      }
function accept()
      {
x=window.prompt("enter the value");
y=window.prompt("enter the value");
     }   
   </SCRIPT>
   <BODY>
   <FORM NAME=f1>
    <CENTER>
        <INPUT TYPE=BUTTON NAME=B1 VALUE="  +  " onClick="fadd_click()">&nbsp&nbsp&nbsp
      <INPUT TYPE=BUTTON NAME=B4 VALUE="  -  " onClick="fdiff_click()">&nbsp&nbsp&nbsp
      <INPUT TYPE=BUTTON NAME=B2 VALUE="  *  " onClick="fmult_click()">&nbsp&nbsp&nbsp
      <INPUT TYPE=BUTTON NAME=B3 VALUE="/" onClick="fQuo()">&nbsp&nbsp&nbsp
      <INPUT TYPE = TEXT NAME="c">&nbsp&nbsp&nbsp
   </center>
  </FORM>
  </BODY>
</HTML>





MVC CURD OPERATIONS WITH KENDO GRID

First Go to Master Page.


And add the following line of Code. Now when I click on Employee the Details should be displayed to me.


Now I need to create an Employee Controller. Before That I would like to

1 Create a Folder with View Models.
 2 create a class with name “EmployeeViewModel” to add gets and sets properties.



Go to EmployeeViewModel.cs and write the following lines of Code.

public class EmployeeViewModel
    {
public int Employeeno { get; set; }
       public string EmployeeName { get; set; }
       public string EmployeeAddress { get; set;}       
public List<EmployeeViewModel> lstEmployees { get; set; }
     }


Add the Reference of Kendo

And then go to Web.Config  and add namespace for Kendo ( in both the web.config files)
1 which is inside View Folder
2 which is outside


 <add namespace="Kendo.Mvc.UI" />

To Apply Styles
Go to Content Folder, all the styles related to Kendo need to be paste here.



All the scripts files related to Kendo need to be in Scripts Folder


Then go to master page (layout.cs.html) under View Folder and add the following styles and js files related to Kendo.

@Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    <link href="@Url.Content("~/Content/Kendo/kendo.common.min.css")" rel="stylesheet"/>
    <link href="@Url.Content("~/Content/Kendo/kendo.default.min.css")" rel="stylesheet"/>
    <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Kendo/jquery.min.js")" type="text/javascript"></script>

  
    <script src="@Url.Content("~/Scripts/Kendo/kendo.all.min.js")" type="text/javascript"></script>

    <scriptsrc="@Url.Content("~/Scripts/Kendo/kendo.aspnetmvc.min.js")" type="text/javascript"></script>






And comment the following lines of code below in master page.

    @*    @Scripts.Render("~/bundles/jquery")

        @RenderSection("scripts", required: false)*@


Then go to Model and Create a model with a name Employee.cs


Add-> new item



And write  the following line of code in Employee.cs as below






Then go to controller folder , and select



And Click On Add button.

Write the following Methods in Employee Controller as follows:











So go to Controller and Right click on Selected Method Name i.e. (EmployeeGrid)




And select Add view


And write  the following code in View



Run the application and see the output.




Now I want to display the Edit Details in Pop up.

So change the following line of code as


 And see the output



And click on Edit Button or Add New Record Button.



If you want to hide any column,  then go to EmployeeViewModel and write the property as
[HiddenInput(DisplayValue = false)]



Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...