Dhtmlx Gantt Chart - Minor Issue - gantt-chart

I've set up DHTMLX Gantt Chart (http://dhtmlx.com/docs/products/dhtmlxGantt/index.shtml). I'm loading raw xml data as opposed to an xml file.
However, I get an alert saying 'Cannot Parse This XML String'. But when I click 'OK' the Gantt Chart appears as normal.
Below is the code I'm working with:
var $_ = jQuery;
$_(document).ready(function() {
window.createChartControl = function(htmlDiv1){
var ganttChartControl = new GanttChart();
ganttChartControl.setImagePath("../../../../lib/plugins/html/gui/dhtmlx/gantt/1.3/codebase/imgs/");
ganttChartControl.create(htmlDiv1);
var xml_data_str = '<projects><project id="1" name="Project 1" startdate="2006,12,14"><task id="1"><name>Task 1 of Project 1</name><est>2006,12,14</est><duration>20</duration><percentcompleted>20</percentcompleted><predecessortasks></predecessortasks><childtasks><task id="11"><name>Sub Task 1 of Task 1 of Project 1</name><est>2006,12,14</est><duration>5</duration><percentcompleted>10</percentcompleted><predecessortasks></predecessortasks><childtasks></childtasks></task><task id="12"><name>Sub Task 2 of Task 1 of Project 1</name><est>2006,12,15</est><duration>10</duration><percentcompleted>20</percentcompleted><predecessortasks>11</predecessortasks><childtasks></childtasks></task></childtasks></task></project><project id="2" name="Project 2" startdate="2006,12,17"><task id="2"><name>Task 1 of Project 2</name><est>2006,12,17</est><duration>60</duration><percentcompleted>20</percentcompleted><predecessortasks></predecessortasks><childtasks><task id="21"><name>Sub Task 1 of Task 1 of Project 2</name><est>2006,12,17</est><duration>40</duration><percentcompleted>20</percentcompleted><predecessortasks></predecessortasks><childtasks></childtasks></task></childtasks></task></project></projects>';
ganttChartControl.loadData(xml_data_str, false, false);
}
window.createChartControl('chart_dhtmlx_gantt_2');
});
The relevant bit is the XML data. Is there something wrong with the way I've set it up?!
Kindly assist.
Thanks.

Check out this post on the forum
http://forum.dhtmlx.com/viewtopic.php?f=15&t=15909&p=48639&hilit=loaddata#p48639
There is a bug in the code ...

Related

Cannot find Excel in Javascript Chart API

I was trying to use this Microsoft tutorial Excel Chart Add-in - Javascript API
In the first example, it has the code
Excel.run(function (context) {
var sheet = context.workbook.worksheets.getItem("Sample");
var dataRange = sheet.getRange("A1:B13");
var chart = sheet.charts.add("Line", dataRange, "auto");
chart.title.text = "Sales Data";
chart.legend.position = "right"
chart.legend.format.fill.setSolidColor("white");
chart.dataLabels.format.font.size = 15;
chart.dataLabels.format.font.color = "black";
return context.sync();
}).catch(errorHandlerFunction);
If I run the code example I receive 2 errors. One that it cannot find excel from
Excel.run
And the errorhandler function is not defined, which appears to be correct.
Are these typos in new Microsoft documents? If not what have I got to change?
Version: excel 365 online build 16.0.13615.35052
2 things that you need to make sure you have in order to run this code succesfully.
Please add the errorHandlerFunction this could be be as easy as this:
function errorHandlerFunction(e ){
console.log("exception" + e );
}
Make sure you have a worksheet named "Sample". Make sure its exactly that name without trailing blank spaces.

NetSuite - Generating Excel with SuiteScript 2.0 keeps corrupting upon opening

Hope you can assist.
I have a scheduled script in SuiteScript 2.0, which does the following:
1) Loads a XML file from the filing cabinet (code snippet below):
var fileObj = FILEMODULE.load({id: fileId });
if (fileObj.size < 10485760){
log.debug('units to start with', RUNTIMEMODULE.getCurrentScript().getRemainingUsage());
log.debug('file contents', fileObj.getContents());
return fileObj.getContents();
}
This XML file is used as a template for the Excel generation.
2) Runs a saved search and calls a function inside the result loop to formulate the rows and cells:
content += '<Row>'
content += '<Cell ss:StyleID="s67"><Data ss:Type="String">' + data + '</Data></Cell>';
End of the loop, we close the "<Row>" with "</Row>"
3) Lastly we add the final bit of HTML code to the content string used for the content of the Excel file:
content += '</Table></Worksheet></Workbook>';
4) Creates a file, and uploads to filing cabinet
var xlsFile = FILEMODULE.create({name: 'TEST.xls', fileType: 'EXCEL', contents: base64EncodedString});
xlsFile.folder=1173; //folder name=XML Templates
var fileID = xlsFile.save();
BUT....
5) Upon opening without data, it works fine (this confirms the XML template is fine).
6) Upon opening with 2 lines of data from the search, it works fine. All 26 columns print in the cells.
7) After this, adding more than 2 lines causes a corruption error. File refuses to open.
I have used XML beautify tools online to inspect the xml code and honestly, the code of line 1 and 2, really does not look much different line 3 onwards.
Checking the excel file out on Notepad++ to inspect the xml code, all new rows register as one line (as opposed to a new line) - notice the screenshot which stops at line 169... Could this be why?
Any ideas on diagnosing this will be most appreciated.
Note: The initial template was built through creating the headings in the style/format I wanted on Excel, then saving as "XML Spreadsheet".
we can't really see everything you're doing so debugging is tough.
One thing is you should escape all your data. So include N/xml and :
content += '<Cell ss:StyleID="s67"><Data ss:Type="String">' + data + '</Data></Cell>';
should be:
content += '<Cell ss:StyleID="s67"><Data ss:Type="String">' + xml.escape({xmlText:data}) + '</Data></Cell>';
You're statement about looping with a row and then ending sounds like you may have
<Row><Cell/><Cell/> //not closing the row for each row of search results.
<Row><Cell/><Cell/>
<Row><Cell/><Cell/>
...
</Row>
For clarity you may want to output a line feed after each row. Check the spec XML should allow only line feeds but since this is an MS format they may want CRLF instead.
so for each row:
content += '</Row>\n';

Automation error in getting Childnodes by number of item ChildNodes(0) in VBA Excel

I am using code to get values of HTML attributes like:
Set myPhoto = doc.DocumentElement.getElementsByTagName("ul"): i = 2
For Each e In myPhoto
...
MyNodeValue = Trim(e.ChildNodes(0).ChildNodes(0).ChildNodes(0).src)
...
next
It has been working well until now. Excel shows me "Automation error" in case nodespath is exist.
The code string work well if use Children(0) vs Childnodes(0) like:
MyNodeValue = Trim(e.Children(0).Children(0).Children(0).src)
I can't understand what happened with code and why ChildNodes(0) doesn't work?

Error in send variable Stimulsoft

i use Stimulsoft for my project however this problam stop my project
my code:
string cn1 = #"data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\Report.mrt;integrated security=True;connect timeout=30;Encrypt=False;TrustServerCertificate=False;MultipleActiveResultSets=True;";
stiReport1.Load("Report.mrt");
stiReport1.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection11", cn1));
stiReport1.Dictionary.Variables["Variable1"].Value =textBox1.Text;
stiReport1.Render(false);
this.stiViewerControl1.Report = stiReport1;
this.stiViewerControl1.Refresh();
when i run that and fill textbox and submit :
Invalid column name 'اهواز'.
please help me
check DataSource columns name in StiReport Designer

pentaho modify and print a parameter while exporting to excel

I use pentaho report designer. I have got businessdate parameter in my prpt file. This has the value of the date range which is used to filter the sql query. I am able to handle and modify it while exporting to html however I have a problem in exporting to excel.
The date range comes in the formats below:
- BETWEEN {d '2014-01-01'} AND {d '2014-01-31'}
- IN ({d '2014-01-14'},{d '2014-01-15'}, {d '2014-01-19'} ,{d '2014-01-20'},{d '2014-01-21'})
I like to find out max and min date and display it. However in this case with excel, I am happy with displaying them separated with commas like shown below.
- 2014-01-01, 2014-01-31
- 2014-01-14, 2014-01-15, 2014-01-19, 2014-01-20, 2014-01-21
If I use the basic formula show below, it works in in excel but it does not work when I apply it to excel - formula section of the businessDate element in pentaho report designer.
=TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B4,"{d '",""), "BETWEEN", ""), "IN", ""),"'}",", "), " AND ", ""),")",""),"(",))
It does not have to be this way. I am happy with any method suggested to format this raw date range before printing to excel.
Thank you in advance.
After wasting a lot of time, I have found a way which works for all export types. As I said in my question, I was modifying date for html print by using "Structure Tab" --> Select "Master Report" --> "Attributes" Tab --> html -> "append-header" attribute.
<script type="text/javascript">
function init() {
var tableList = document.getElementsByTagName("table");
var businessDate = document.getElementById("businessDatePeriodSelected");
businessDate.innerHTML = businessDate.innerHTML+"testDateModified";
}
window.onload = init;
</script>
This piece of code does the job. However just for html. I needed to come up with something new. I was looking for a solution for excel and pdf exports as well.
HERE IS THE SOLUTION:
Click on "Data" tab next to the "Structure" tab on the right top side. You will see "Functions" in the tree. Right click and hit "Add functions". Select "Script" -->"Bean-Scripting Framework (BSF)". Select function created under Functions. Give it a name and add the code below to the "Expression" section. [This does not need a starting or ending tag]
/* businessdate is one of my parameters that I like to display on the report.
dataRow is automatically recognized by the interpreter which can be used for calling parameter values. It seems like came out of nowhere.*/
String value = dataRow.get("businessdate");
value= value.replaceAll("[^0-9\\-\\{\\}]", "");
value= value.replaceAll("[\\{]", ""); // replace all {
value= value.replaceAll("[\\}]", ","); // replace all }
value= value.substring(0, value.length()-1);
String[] dateArr = value.split(",");
return dateArr[0] +" - "+dateArr[dateArr.length-1];
The last thing you need to do is drag and drop your function somewhere suitable on your report. It will locate a textbox which will display the modified businessdate.
If you like to print a parameter on your pentaho report, this does the job for all exports (html, pdf and excel). You can also modify it before printing. This link pretty helpful as the syntax is slightly different at some points.
good luck.

Resources