Change file name before a save
Change file name before a save
Hi,
I want to use a prompt to allow the user to change his report fileName. For example, when I click on save, I want to pop a prompt to allow him to change the filename.
Is it possible to use the same prompt that you used when we click on "save as" ?
I want to use a prompt to allow the user to change his report fileName. For example, when I click on save, I want to pop a prompt to allow him to change the filename.
Is it possible to use the same prompt that you used when we click on "save as" ?
- Attachments
-
- What I want to use
- Capture.PNG (5.62 KiB) Viewed 5924 times
Re: Change file name before a save
You can add a onSave/onSaveAs Hook:
https://admin.stimulsoft.com/documentat ... savereport
var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
designer.onSaveAsReport = function (e) { // or onSaveReport
this.designer.report.reportName="My Cool Name"; // sets the report name...
};
I didn't figure out a method to use then the default Stimulsoft JS Messagebox - so I added SweetAlert2
https://www.npmjs.com/package/sweetalert2
or the angular2 version
https://www.npmjs.com/package/ng2-sweetalert2
https://admin.stimulsoft.com/documentat ... savereport
var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
designer.onSaveAsReport = function (e) { // or onSaveReport
this.designer.report.reportName="My Cool Name"; // sets the report name...
};
I didn't figure out a method to use then the default Stimulsoft JS Messagebox - so I added SweetAlert2
https://www.npmjs.com/package/sweetalert2
or the angular2 version
https://www.npmjs.com/package/ng2-sweetalert2
Re: Change file name before a save
Thanks for your answer harryf75,
I know I could use the onSave hook, but I wanted to use the default Stimulsoft JS Messagebox to get the user's text.
But nevermind, if it is impossible I will use something else, even it's a pity.
I know I could use the onSave hook, but I wanted to use the default Stimulsoft JS Messagebox to get the user's text.
But nevermind, if it is impossible I will use something else, even it's a pity.
Re: Change file name before a save
At last from my knowlege only this works.
Did you try saving the hook and calling it? This might works...
var old = designer.onSaveAsReport;
designer.onSaveAsReport = function (e) { // or onSaveReport
this.designer.report.reportName="My Cool Name"; // sets the report name...
old();
};
Did you try saving the hook and calling it? This might works...
var old = designer.onSaveAsReport;
designer.onSaveAsReport = function (e) { // or onSaveReport
this.designer.report.reportName="My Cool Name"; // sets the report name...
old();
};
Re: Change file name before a save
In this way, it is the Developer who set the name I wanted the user to set himself the name of the document in a onSaveReport only if the user use one of my documents, to save this report in an other file.
Here is my function if it could help to understand :
Here is my function if it could help to understand :
Code: Select all
designer.onSaveReport = function (e) {
var jsonString = e.report.saveToJsonString();
var today = new Date();
var date = today.getDate() + '_' + parseInt(today.getMonth()+1) + '_' + today.getFullYear();
var defaultName = 'document_' + date;
e.fileName = defaultName;
if (iscustom() == 1){
e.fileName = getFileName();
}else{
//A MessageBox will open and the user have to tape his own fileName.
}
}
Re: Change file name before a save
I wrapped the whole Designer into my own panel.
In my software I have system default report. The user can have a "Copy of..." report and also rename the report. And I have a rename method.
In my software I have system default report. The user can have a "Copy of..." report and also rename the report. And I have a rename method.
- Attachments
-
- designer.png (25.35 KiB) Viewed 5905 times
Re: Change file name before a save
That is a possibility, maybe I will do something like this.
A message popup would have been better for me but nevermind.
Thanks for your answer.
A message popup would have been better for me but nevermind.
Thanks for your answer.
-
- Posts: 4
- Joined: Tue Feb 27, 2018 5:23 pm
Re: Change file name before a save
hi
were you able to use the stimulsoft's pop up ?PaPy wrote:That is a possibility, maybe I will do something like this.
A message popup would have been better for me but nevermind.
Thanks for your answer.
Re: Change file name before a save
Hello,
Please try to use the following code:
Thank you.
Please try to use the following code:
Code: Select all
var designer = new Stimulsoft.Designer.StiDesigner(null, "StiDesigner", false);
designer.renderHtml("content");
designer.jsObject.InitializeSaveReportForm(function (saveReportForm) {
saveReportForm.action = function () {
this.changeVisibleState(false);
var fileName = this.reportNameTextBox.value;
//write your code here
alert(fileName);
if (this.nextFunc) this.nextFunc();
}
});