?
Solved

kendo spreadsheet

Posted on 2016-07-22
2
Medium Priority
?
601 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:Seven price
[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 2000 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:Seven price
ID: 41730436
Sorry I thought I  closed this. I figured it out with the top 2 help thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn what comprises a theme in Excel 2013, as well as how to customize them.
Viewers will learn the basics of the new Quick Analysis feature in Excel 2013.

719 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