Solved

kendo spreadsheet

Posted on 2016-07-22
2
378 Views
Last Modified: 2016-07-26
I am using kendo spreadsheet and all my data is returning json values.
Question can i format the grid as far as rename headers or position my data where I want to. Not much info on how when it is dynamically coming from the server.
  $("#spreadsheet").kendoSpreadsheet({
      //          columns: 50,
      //          rows: 100,
      //          toolbar: true,
      //          sheetsbar: true,
      //          sheets: [{
      //              name: "Summary",
      //                    mergedCells: [
      //         // "A1:D1"  // Sheet Cell Placement , "C4:G4", "O4:R4", "A13:B13", "A16:B16"
      //                    ],
      //             rows: [{
      //          height: 30,
      //          cells: [{
      //            value: "label", background: "rgb(144,164,174)", textAlign: "center",
      //                      color: "white", fontSize: 18
      //          },
      //          ],
      //      }, 
      //      {
      //               index: 3,
      //               cells: [
      //                  {   index: 2, value: "Mean Total Returns(net)", fontSize: 15, textAlign: "center"}
      //                ],
                  
      //          },
      //        {
      //               index: 3,
      //               cells: [
      //                  {   index: 14, value: "Mean Asset Allocation", fontSize: 15, textAlign: "center"}
      //                ],
                  
      //        }],
                 
      //            dataSource:  dataSource, 
      //              columns: [
      //                  { width: 100 },
      //                  { width: 415 },
      //                  { width: 145 },
      //                  { width: 145 },
      //                  { width: 145 }
      //              ],
               
      //          }]
      //      });
           

Open in new window

0
Comment
Question by:sevensnake77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 41725530
I have only looked at kendo but your data source is going to be generated jsonp

https://demos.telerik.com/kendo-ui/spreadsheet/datasource
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="styles/kendo.common.min.css" />
    <link rel="stylesheet" href="styles/kendo.default.min.css" />
    <link rel="stylesheet" href="styles/kendo.default.mobile.min.css" />

    <script src="js/jquery.min.js"></script>
    <script src="js/jszip.min.js"></script>
    <script src="js/kendo.all.min.js"></script>
</head>
<body>
<div id="example">
    <div class="box wide">
        <div class="box-col">
        <h4>Save data changes</h4>
        <ul class="options">
            <li>
                <button class="k-button" id="save">Save changes</button>
                <button class="k-button" id="cancel">Cancel changes</button>
            </li>
        </ul>
        </div>
    </div>

    <div id="spreadsheet" style="width: 100%"></div>
    <script>
        $(function() {
            var crudServiceBaseUrl = "//demos.telerik.com/kendo-ui/service";

            var dataSource = new kendo.data.DataSource({
                transport: {
                    read:  {
                        url: crudServiceBaseUrl + "/Products",
                        dataType: "jsonp"
                    },
                    update: {
                        url: crudServiceBaseUrl + "/Products/Update",
                        dataType: "jsonp"
                    },
                    destroy: {
                        url: crudServiceBaseUrl + "/Products/Destroy",
                        dataType: "jsonp"
                    },
                    create: {
                        url: crudServiceBaseUrl + "/Products/Create",
                        dataType: "jsonp"
                    },
                    parameterMap: function(options, operation) {
                        if (operation !== "read" && options.models) {
                            return {models: kendo.stringify(options.models)};
                        }
                    }
                },
                batch: true,
                change: function() {
                   $("#cancel, #save").toggleClass("k-state-disabled", !this.hasChanges());
                },
                schema: {
                    model: {
                        id: "ProductID",
                        fields: {
                            ProductID: { type: "number" },
                            ProductName: { type: "string" },
                            UnitPrice: { type: "number" },
                            Discontinued: { type: "boolean" },
                            UnitsInStock: { type: "number" }
                        }
                    }
                }
            });

            $("#spreadsheet").kendoSpreadsheet({
                columns: 20,
                rows: 100,
                toolbar: false,
                sheetsbar: false,
                sheets: [{
                    name: "Products",
                    dataSource: dataSource,
                    rows: [{
                        height: 40,
                        cells: [
                        {
                            bold: "true",
                            background: "#9c27b0",
                            textAlign: "center",
                            color: "white"
                        },{
                            bold: "true",
                            background: "#9c27b0",
                            textAlign: "center",
                            color: "white"
                        },{
                            bold: "true",
                            background: "#9c27b0",
                            textAlign: "center",
                            color: "white"
                        },{
                            bold: "true",
                            background: "#9c27b0",
                            textAlign: "center",
                            color: "white"
                        },{
                            bold: "true",
                            background: "#9c27b0",
                            textAlign: "center",
                            color: "white"
                        }]
                    }],
                    columns: [
                        { width: 100 },
                        { width: 415 },
                        { width: 145 },
                        { width: 145 },
                        { width: 145 }
                    ]
                }]
            });

            $("#save").click(function() {
                if (!$(this).hasClass("k-state-disabled")) {
                    dataSource.sync();
                }
            });

            $("#cancel").click(function() {
                if (!$(this).hasClass("k-state-disabled")) {
                    dataSource.cancelChanges();
                }
            });
        });
    </script>
</div>


</body>
</html>

Open in new window


Your processing page just needs to produce jsonp.  The example above is hard coded but you can generate the same rendered code through your server side code.

Where you see the datasource
var dataSource = new kendo.data.DataSource({
                transport: {
                    read:  {
                        url: crudServiceBaseUrl + "/Products",
                        dataType: "jsonp"
                    },
                    update: {
                        url: crudServiceBaseUrl + "/Products/Update",
                        dataType: "jsonp"
                    },
                    destroy: {
                        url: crudServiceBaseUrl + "/Products/Destroy",
                        dataType: "jsonp"
                    },
                    create: {
                        url: crudServiceBaseUrl + "/Products/Create",
                        dataType: "jsonp"
                    },
                    parameterMap: function(options, operation) {
                        if (operation !== "read" && options.models) {
                            return {models: kendo.stringify(options.models)};
                        }
                    }
                },

Open in new window

it is the urls like Products where you produce your dynamic content.

To pass variables, use jquery to past post/get and data
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data
 data: [
    { name: "Jane Doe" },
    { name: "John Doe" }
  ]

Open in new window


They do have examples for .net https://demos.telerik.com/aspnet-mvc/spreadsheet/datasource

Your dynamic data comes from the processing page in that case
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 41730436
Sorry I thought I  closed this. I figured it out with the top 2 help thanks.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
Viewers will learn the basics of the new Quick Analysis feature in Excel 2013.
Video by: Zack
Viewers will learn the basics of using Excel Tables, the benefits found with them, and some pitfalls.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question