How to Show multiple kendo grids using dynamic data in Html using Jquery

1.Declare a div element to bind the gird

ex:   <div class="container-fluid">
               <div id="Equipmentgrid"></div>
         </div>

2. Get the data using ajax call

ex: <script>
        var EquipmentData;
        var EmployeeDat;

                $.ajax({
                    type: 'GET',
                    url: "WS_Equipment.asmx/GetEquipmentData",
                    data: { WeekendingDate: WeekendingDate, WorkOrderId: WorkOrderId },
                    dataType: "json",
                    success: function (jsonData) {
                        var i = JSON.parse(JSON.stringify(jsonData));
                        if (jsonData != null) {
                            //JSON.parse(JSON.stringify(jsonData.Employee));
                            EquipmentData = i.Equipment;
                            EmployeeDat = i.Employee;
                            BindGrid();
                        }

                    },
                    error: function (error) {
                        alert(error.responseText)
                    }
                });
 </script>

3.Declare the schema

ex: EquipmentData = new kendo.data.DataSource({
                data: EquipmentData,
                batch: true,
                pageSize: 5,
                schema: {
                    model: {
                        id: "Id",
                        fields: {
                            HeaderId: { type: "string" },
                            JobNumber: { type: "string" },
                            WorkOrderNumber: { type: "string" },
                            WeekendingDate: { type: "string" },
                            EquipmentType: { type: "string" },
                            Service_ID: { type: "string" },
                            Hours: { type: "string" },
                            CreatedBy: { type: "string" },
                            CreatedDate: { type: "string" },
                            UpdatedBy: { type: "string" },
                            UpdatedDate: { type: "string" },
                        }
                    },

                }
            });


4. Define the grid and columns to display with respective titles

ex:$("#Equipmentgrid").kendoGrid({
                dataSource: EquipmentData,
                pageSize: 5,
                pageable: true,
                sortable: true,
                pageable: {
                    alwaysVisible: true,
                    pageSizes: [5, 10, 20, 100],
                    refresh: true,
                    buttonCount: 10
                },
                columns: [{
                    field: "HeaderId",
                    filterable: false,
                    width: 100
                },
                {
                    field: "JobNumber",
                    title: "Job Number",
                    width: 200

                }, {
                    field: "WorkOrderNumber",
                    title: "Work Order Number",
                    width: 200
                }, {
                    field: "EquipmentType",
                    title: "Equipment Type",
                    width: 200
                }, {
                    field: "Hours",
                    title: "Hours",
                    width: 200
                },
                {
                    command: [{
                        name: "edit",
                        className: "btn-Edit",
                        text: "Edit", click: btnEdit
                    }], title: "Edit Data", media: "(min-width: 500px)", width: "110px"
                },
                {
                    command: [{
                        name: "GenerateReport",
                        className: "btn-markavailable",
                        text: "Generate Report", click: btnGenerateReport
                    }], title: "Generate Report", media: "(min-width: 500px)", width: "220px"
                },
                {
                    command: [{
                        name: "GFSign",
                        className: "btn-Delete",
                        text: "GFSign", click: btnGFSign
                    }], title: "GFSign", media: "(min-width: 500px)", width: "110px"
                },
                {
                    command: [{
                        name: "CustomerSign",
                        className: "btn-ignore",
                        text: "CustomerSign", click: btnCustomerSign
                    }], title: "CustomerSign", media: "(min-width: 500px)", width: "220px"
                }
                ]
            });



Note:  Add below scripts in your page

  <script src="js/jquery.min.js"></script>
    <script src="js/jszip.min.js"></script>
    <script src="js/kendo.all.min.js"></script>

Comments

Popular posts from this blog

How to get the user details, user current level, next level, Rank in sql server

How to update the user level when ever user report any tweet in sql

Implement virtualisation in kendo drop down list using jquery ajax in mvc, aspx page