<div id="Spreadsheet"></div>
$(function () {
$("#Spreadsheet").ejSpreadsheet({
//...
loadComplete: "onLoadComplete"
});
});
function onLoadComplete(args) {
//Collapse ribbon option
$("#" + this._id + "_Ribbon").data("ejRibbon").collapse();
}
|
Hi Silambarasan,
Thank you, but it did not work on my end. Here is what I have:
@(Html.EJ().Spreadsheet<object>("Spreadsheet")
.AllowEditing(true)
.AllowImport(true)
.AllowInsert(true)
.ColumnWidth(100)
.AllowResizing(true)
.AllowFreezing(true)
.AllowFormulaBar(true)
.ShowRibbon(true).RibbonSettings(x => x.EnableOnDemand(true))
.EnableContextMenu(true)
.ScrollSettings(scroll => { scroll.Height(580); })
.ExportSettings(x => x.AllowExporting(true))
.ImportSettings(import =>
{
import.ImportOnLoad(Model.ExcelData != null);
import.ImportMapper(Url.Action("ImportXls", "ExcelData"));
})
.ClientSideEvents(x=>x.LoadComplete("onLoadComplete"))
)
then I have a script:
$(function() {
$("#saveXls").bind("click",
function() {
function onLoadComplete(args) {
$("#Spreadsheet_Ribbon").data("ejRibbon").collapse(); }
});
I also tried $("#" + this._id + "_Ribbon").data("ejRibbon").collapse();
but that did not work either. I see that your example is working. So the question is what is the difference between the MVC extension and the js plugin.
Thanks for all your help.
On a different note, how do you paste code with formatting in this editor? I like how your code looks, nice and formatted.
@(Html.EJ().Spreadsheet<object>("Spreadsheet")
//...
.ClientSideEvents(x => x.LoadComplete("onLoadComplete"))
)
<script type="text/javascript">
//$(function () {
// $("#saveXls").bind("click", function () {
// function onLoadComplete(args) {
// $("#Spreadsheet_Ribbon").data("ejRibbon").collapse();
// }
// });
//});
//onLoadComplete function should be defined outside of document.ready function & it should be available in window scope.
function onLoadComplete(args) {
$("#Spreadsheet_Ribbon").data("ejRibbon").collapse();
}
</script>
|
Thank you for the information. It worked beautifully. The key was this;
//onLoadComplete function should be defined outside of document.ready function & it should be available in window scope.
Thank you for the formatting tip too.