How to define the spreadsheet columns off a remote dataset?

1 Answer 11 Views
Spreadsheet wrapper
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 05 Apr 2024, 02:30 PM

So this is my datasource... I would assume the schema is what it would read to render the properties in the sheet, but it's just verbatim taking the JSON object and plopping it in.  So example, there's a LastUpdated property on each object, it's not defined in the schema... but it's rendering in the sheet.

Am I missing something?

 dataSource: {
            transport: {
                dataType: "json",
                read: {
                    url: this.baseUrl + "/groups?format=json",
                    type: "GET",
                    data: function () {
                        return {
                            cohort: $editorData.cohort
                        };
                    }
                },
                /*
                update: {
                    url: baseUrl + "/groups?format=json",
                    dataType: "json",
                    type: "POST"
                },
                */
            },
            requestEnd: function (e) {
                var response = e.response;
                var type = e.type;
                
                console.log("requestEnd", type, response);
            },
            schema: {
                model: {
                    id: "UserId",
                    fields: {
                        UserName: { type: "string", editable: false },
                        FirstName: { type: "string", editable: false },
                        LastName: { type: "string", editable: false },
                        Campus: { type: "string", editable: false },
                        Cohort: { type: "number", editable: false },
                        MF1: { type: "number" },
                        MF3: { type: "number" },
                        MF4: { type: "number" },
                        MF2: { type: "number" },
                        MF5: { type: "number" },
                        ClerkshipGroup: { type: "number" },
                        PediatricsStream: { type: "number" },
                        ProCompGroup: { type: "number" }
                    }
                }
            },



            <kendo-spreadsheet 
              ref="spreadsheet"
             :toolbar="false" 
             :sheetsbar="false"
             :excel-proxy-URL="'/RestApi/utility/proxy/save'"
             :pdf-proxy-URL="'/RestApi/utility/proxy/save'"
             :columns="15"
             :rows="300"
             style="width: 100%; height: 800px">
                        <kendo-spreadsheet-sheet 
                            :name="'Groups'" 
                            :data-source="dataSource"
                            :rows="rows"
                            :columns="columns"
                        >
                        </kendo-spreadsheet-sheet>
            </kendo-spreadsheet>

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 10 Apr 2024, 12:50 PM

Hello, Steve,

The purpose of the scheme is to set additional options to the fields (like type, validation, etc), but it does not affect the columns rendered in the Spreadsheet. If you want to hide a column you can either remove it from the data or use the "hideColumn" method of the sheet loading it.

Another option would be to set the width of the columns that you would like to hide to 0:

      columns: [
        { width: 0 },
        { width: 415 },
        { width: 145 },
        { width: 145 },
        { width: 145 },
      ],

I hope the provided information will be helpful for you.

Regards,
Vessy
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
commented on 10 Apr 2024, 01:28 PM

Hmm, can it somehow be a feature request? Don't have control over the structure of the JSON and I'd rather it not be showing up in the sheet, user's gonna notice A | B | D (no C) on the col line.  I assume there's larger workarounds with the datasource and massaging after requestEnd or something, but would be nice to just POINT it at a source and be done with less code, sheet respects the schema and property order.

 

Vessy
Telerik team
commented on 10 Apr 2024, 03:20 PM | edited

Sure, Steve, you can submit a feature request for the desired functionality directly in the Kendo UI for jQuery feedback portal here:

Tags
Spreadsheet wrapper
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Vessy
Telerik team
Share this question
or