8 Answers, 1 is accepted
Hello Kevin,
Currently, this is not possible via the initial configuration. However, it is possible when using setDataSource method of the Sheet. Similar to the following:
var
spreadsheet = $(
"#spreadsheet"
).data(
"kendoSpreadsheet"
);
var
sheet = spreadsheet.activeSheet();
sheet.setDataSource(dataSource, [
{ field:
"ProductID"
, title:
"Product ID"
},
{ field:
"ProductName"
, title:
"Product Name"
},
{ field:
"UnitPrice"
, title:
"Unit Price"
}
]);
Regards,
Rosen
Telerik
Where would this code be placed on the page as I am having the same issue.
I tried the sheet.RequestEnd which works as you described when the page loads but as soon as I start to try and edit any of the cells in the spreadsheet the page freezes with a long running script error. If I comment out the code and just load the whole table everything works fine
thanks
Jeff Murtari
Hello Jeff,
The code in question should be executed at the point where it is appropriate to set the DataSource instance for your specific scenario. For example if you want to set the DataSource during initial loading you could use a document ready to do so.
Regards,Rosen
Telerik
Hello Jeff,
Just to add about the approach you have tried. You should not use requestEnd to change the DataSource instance as this could result in an endless loop,. which I suspect is the behavior you are experiencing.
Regards,Rosen
Telerik
Rosen thanks for the quick reply. Would you have a quick example as I am having some issues with the document ready.
I have the datasource set in the sheet .Read command but am trying to limit the columns displayed. The trouble I seem to be having with the documentready is that the datasource is set at the .Sheet level and not the spreadsheet control level
thanks
jeff
Rosen I have gotten the document ready script to work so thank you for pointing me in the right direction. Now just having an issue when I try to update a date field in the spreadsheet but will open another ticket
thanks again
I referred your above code while using setDataSource method. But the field column names looks static or fixed here. For me I have the column names generated dynamically and it may vary in number. I will have the field and title values but how can I use the loop to iterate through the variables to set the respective field and title values in above code?
Please let em know.
You could retrieve the dynamically generated columns by the following code:
<script>
var
sheet = $(
"#spreadsheet"
).data(
"kendoSpreadsheet"
).activeSheet();
var
columns = sheet.dataSourceBinder.columns;
console.log(columns);
</script>
Check out the following Dojo example, where after the SpreadSheet data is bound, the columns of the sheet are being logged in the browser console. You should be able to then iterate over them and process them further depending on the project requirements.
Regards,
Dimitar
Progress Telerik