getorgchart secondParentIdField error with html table or csv source - getorgchart

I'm testing getorgchart and require secondary parent on some entries.
Whenever I run I get error:
TypeError: t is undefined
If I comment out the following line it loads and shows the chart - without the seocndard links:
secondParentIdField: "secondKey",
I'm using HTML tables as the source, I've also tried CSV.
I have found this which links back to the original documentation:
GetOrgChart-multiple parents for a child node
This is using JSON as the source and list secondParenId only when needed (example: http://www.getorgchart.com/Demos/Second-Parent-Relation)
I wonder if this is a mark up issue with HTML/CSV vs JSON. I've tried adding value null and 0 to the html table but it still shows the same error.
HTML Table Source - note that I'm editing the example files so it's loading jquery and the getorgchart files correclty:
<table id="orgChartData">
<tr>
<th>Key</th>
<th>parentKey</th>
<th>secondKey</th>
<th>team</th>
<th>name</th>
<th>title</th>
<th>email</th>
<th>dd</th>
<th>mob</th>
<th>image</th>
</tr>
<tr>
<td>1</td>
<td></td>
<td></td>
<td></td>
<td>Test 1</td>
<td>Tile 1</td>
<td>email1#email.co.uk</td>
<td>0000 123456</td>
<td>0000 123456</td>
<td>person.jpg</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>3</td>
<td></td>
<td>Test 2</td>
<td>Title 2</td>
<td>email2#email.co.uk</td>
<td>0000 123456</td>
<td>N/A</td>
<td>person.jpg</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td></td>
<td></td>
<td>Test 3</td>
<td>Title 3</td>
<td>email3#email.co.uk</td>
<td>0000 123456</td>
<td>0000 123456</td>
<td>person.jpg</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>2</td>
<td></td>
<td>Test 4</td>
<td>Title 4</td>
<td>email4#email.co.uk</td>
<td>0000 123456</td>
<td>N/A</td>
<td>person.jpg</td>
</tr>
<tr>
<td>5</td>
<td>3</td>
<td></td>
<td>Business Development ePractice</td>
<td>Test 5</td>
<td>Title 4</td>
<td>email5#email.co.uk</td>
<td>0000 123456</td>
<td>0000 123456</td>
<td>person.jpg</td>
</tr>
JavaScript:
<script type="text/javascript">
var peopleElement = document.getElementById("people");
var orgChart = new getOrgChart(peopleElement, {
idField: "Key",
secondParentIdField: "secondKey",
theme: "monica",
linkType: "M",
primaryFields: ["name", "title", "email"],
photoFields: ["image"],
enableGridView: true,
enableEdit: false,
expandToLevel: 2,
dataSource: document.getElementById("orgChartData"),
});
</script>
EDIT:
After some debugging the major difference in the data between JSON & from HTML is:
To get this info add
console.log(this.nodes);
After
for (var e in this.nodes) {
From HTML:
spid: ""
From JSON:
spid: undefined
This is outputting
Fix that worked for me in the code, in function:
getOrgChart.node = function(d, f, h, c, g, e, a, b) {
Add this:
h = (h == "") ? undefined : h;
Before:
this.spid = h;
This would need fixing in the orginal code, I've just de-minified this to debug.

The issue is addressed in the latest version 2.4.5

Related

Creating a custom button in Jodit Editor

I'm trying to create a custom table button using Jodit React Editor using this as reference - https://xdsoft.net/jodit/examples/toolbar/custom_button.html
I'm a little lost on this though.
I need to be able to create a table and have the icon be a text icon that says - "Table"
Right now I've added this to my configurations - extraButtons: ['tableNew'].
I've also added the below code to the render method.
this.jodit.options.controls.tableNew = {
iconURL: '',
exec: function (editor) {
return '<table> <thead> <tr> <th> Sl no </th> <th>Name</th> <th>Age</th> </tr> </thead>'+
' <tbody> <tr> <td>1</td> <td></td> <td></td> </tr> </tbody> </table>';
}
};
I see that a space has been added in the toolbar which on hover says tableNew but on clicking it nothing happens.
I'd really appreciate it if someone could help me out with this.
Instead of the following,
return '<table> <thead> <tr> <th> Sl no </th> <th>Name</th> <th>Age</th> </tr> </thead> <tbody> <tr> <td>1</td> <td></td> <td></td> </tr> </tbody> </table>';
try something like this:
return editor.create.fromHTML('<table> <thead> <tr> <th> Sl no </th> <th>Name</th> <th>Age</th> </tr> </thead> <tbody> <tr> <td>1</td> <td></td> <td></td> </tr> </tbody> </table>');
This works for me (a similiar implementation, not returning table like you, but return some list).

many pandas dataframe to in one readeable file

a=np.array([[1,1,1,1],[2,2,2,2],[3,3,3,3]])
df=pandas.DataFrame(a)
df.to_html('table.html')
I am trying to make pandas.DataFrame to html.
The data are from csv.file, and i split it to several table.
i want make table are in one file one by one.(it's not linked together)
open(filename, mode):
it likes file open with mode 'a',no overwrite original file.
Sample output table like this.
How can i do that or are there another more readable way ?
You can proceed as follows:
put all your dataframes in a list
iterate through them and convert each one to HTML
concatenate all the HTML outputs to one single file
In terms of code, here's how you can do that:
a=np.array([[1,1,1,1],[2,2,2,2],[3,3,3,3]])
b=np.array([[1,4,5,1],[12,2,32,2],[3,32,30,3]])
df_a = pd.DataFrame(a)
df_b = pd.DataFrame(b)
list_df = [df_a, df_b]
output = ""
for index, df in enumerate(list_df):
output += df.to_html() + '<br>'
with open('output.html', 'w') as f:
f.writelines(output)
Here's how the ouput looks like:
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>0</th>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<th>1</th>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<th>2</th>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
</tbody>
</table><br><table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>0</th>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>1</td>
<td>4</td>
<td>5</td>
<td>1</td>
</tr>
<tr>
<th>1</th>
<td>12</td>
<td>2</td>
<td>32</td>
<td>2</td>
</tr>
<tr>
<th>2</th>
<td>3</td>
<td>32</td>
<td>30</td>
<td>3</td>
</tr>
</tbody>
</table><br>

Convert linked images to embedded images

i have an excel file with many images inside.
Actually, this excel files was made with HTML code that converted to excel file and the images were linked to their respective image. ( The reason i made the file with excel is because there is about 700+ images and i cant make it manually from 1. It will takes so much time to finish)
here is my excel's HTML code
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table>
<thead>
<tr>
<th>No</th>
<th>Image</th>
<th>Title</th>
</tr>
</thead>
<tbody>
<tr>
<td >1</td>
<td><img src="56.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >2</td>
<td><img src="57.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >3</td>
<td><img src="58.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >4</td>
<td><img src="59.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >5</td>
<td><img src="60.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >6</td>
<td><img src="61.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >7</td>
<td><img src="62.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >8</td>
<td><img src="63.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >9</td>
<td><img src="64.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >10</td>
<td><img src="65.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >11</td>
<td><img src="66.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >12</td>
<td><img src="67.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >13</td>
<td><img src="68.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >14</td>
<td><img src="69.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >15</td>
<td><img src="70.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >16</td>
<td><img src="71.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >17</td>
<td><img src="72.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >18</td>
<td><img src="73.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >19</td>
<td><img src="74.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >20</td>
<td><img src="75.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >21</td>
<td><img src="76.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >22</td>
<td><img src="77.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >23</td>
<td><img src="78.jpg" width="200px"/></td>
<td></td>
</tr>
<tr>
<td >24</td>
<td><img src="79.jpg" width="200px"/></td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
The problem is, when i save it and send the excel file to other's PC, the images will be blank. Here's the screenshot
i tried to google the problem but still i couldn't find the solution yet.
Any method to convert all the images to embedded images?
Thank you
I wrote a VBA script to convert all linked images to embedded images.
This script will have errors if there are shapes which aren't images. It also assumes that embedded images have their link in their alt text, which I found to be the case in my situation.
Sub INSERT_PICS()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
Debug.Print shp.Name
Debug.Print shp.AlternativeText
ActiveSheet.Shapes.AddPicture Filename:=shp.AlternativeText, linktofile:=msoFalse, _
savewithdocument:=msoCTrue, Left:=shp.Left, Top:=shp.Top, Width:=shp.Width, Height:=shp.Height
shp.Delete
Next shp
End Sub

Excel VBA getElementsByTagName

i'm trying to get a complex (ugly) nested table with no id but with a class name = "tableselect" then read all tr's and td's
the only quick and unique way to find the table - it is within a div tag, then a center tag.
this is the html structure.
<div align="center">
<center>
<table border='1' width='100%' cellspacing='0' cellpadding='5' class="tableselect">
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
...
</table>
</center>
</div>
the .getElementsByTagName("center").getElementsByTagName("table") does not work
also
.getElementsByClassName("tableselect").getElementsByTagName("tr") does not work
using excel 2016

How to pass product TVs to SimpleCart's scGetCart snippet?

I need some TVs (weight, dimensions, etc) I've associated with my products to appear in the Cart page of my SimpleCart site.
Problem is I have no idea how to do this. I don't understand how the SimpleCart cart is built and there isn't documentation for this.
Would anyone know how I can show TVs associated with each product in the cart output chunk?
The cart snippet has the following code which gets data from the cart and puts it into Chunks:
$sc = $modx->getService('simplecart','SimpleCart',$modx->getOption('simplecart.core_path',null,$modx->getOption('core_path').'components/simplecart/').'model/simplecart/',$scriptProperties);
if (!($sc instanceof SimpleCart)) return '';
 
$controller = $sc->loadController('Cart');
$output = $controller->run($scriptProperties);
The output Chunk looks like:
<div id="simplecart">
<form action="[[~[[*id]]]]" method="post" id="form_cartoverview">
<input type="hidden" name="updatecart" value="true" />
<table>
<tr>
<th class="desc">[[%simplecart.cart.description]]</th>
<th class="price">[[%simplecart.cart.price]]</th>
<th class="quantity">[[%simplecart.cart.quantity]]</th>
[[+cart.total.vat_total:notempty=`<th class="quantity">[[%simplecart.cart.vat]]</th>`:isempty=``]]
<th class="subtotal">[[%simplecart.cart.subtotal]]</th>
<th> </th>
</tr>
[[+cart.wrapper]]
[[+cart.total.discount:notempty=`<tr class="total first discount">
<td colspan="[[+cart.total.vat_total:notempty=`3`:isempty=`2`]]"> </td>
<td class="label">[[%simplecart.cart.discount]]</td>
<td class="value">- [[+cart.total.discount_formatted]]</td>
<td class="extra">[[+cart.total.discount_percent:notempty=`([[+cart.total.discount_percent]]%)`:isempty=` `]]</td>
</tr>`:isempty=``]]
[[+cart.total.vat_total:notempty=`
<tr class="total [[+cart.total.discount:notempty=`second`:isempty=`first`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_ex_vat]]</td>
<td class="value">[[+cart.total.price_ex_vat_formatted]]</td>
<td class="extra"> </td>
</tr>
[[+cart.vat_rates]]
<tr class="total [[+cart.total.discount:notempty=`third`:isempty=`second`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_vat]]</td>
<td class="value">[[+cart.total.vat_total_formatted]]</td>
<td class="extra"> </td>
</tr>
<tr class="total [[+cart.total.discount:notempty=`fourth`:isempty=`third`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_in_vat]]</td>
<td class="value">[[+cart.total.price_formatted]]</td>
<td class="extra"> </td>
</tr>
`:isempty=`
<tr class="total [[+cart.total.discount:notempty=`second`:isempty=`first`]]">
<td colspan="2"> </td>
<td class="label">[[%simplecart.cart.total]]</td>
<td class="value">[[+cart.total.price_formatted]]</td>
<td class="extra"> </td>
</tr>
`]]
</table>
<div class="submit">
<input type="submit" value="[[%simplecart.cart.update]]" />
</div>
</form>
This does appear to be documented:
Product Options (TVs)
and to output them:
Modifying the Product Template
It appears that you would just output them normally [[*myProductOptions]]
Though, it appears that your template is using a placeholder, I would try
[[+cart.myProductOptions] as well. If all else fails you might try debugging the simplecart class and dump the array of product data before it populates the chunk, there might be a clue in there.
Found (through trial and error) you must use:
[[+product.tv.name_of_tv]]

Resources