Escaping Data

Tags: #<Tag:0x00007efc6d262f58>

Hello,

How do I escape data show that it shows properly in Handsontable?

Here is my code; the 2nd row is an example of one I am having issues with.

                    <script type="text/javascript">
			const data = [
                                ['AM STD 3x6 ID BLUE BKGD FACE||DWG AS090292||', '1', 'A', '22990461', '2020-04-06', '2020-03-11', '5', '', '0000-00-00', '0000-00-00', '0'],
				['AMOCO 1'9x4'4 TOGO SF CTS SGN(NO LEAF)||DWG BP1024SF_LDSV||FACE: BP184910||', '1', 'A', '35522430', '2020-01-21', '2020-01-02', '5', '•1/20-This will be completed 1/21.', '2020-01-21', '2020-01-21', '1'],

			];
			
			const container = document.getElementById('productionLogTable');
			const hot = new Handsontable(container, {
			  data: data,
			  colHeaders: ['Description', 'Qty', 'LN #', 'Order Number', 'AS400 Ship Date', 'Date Showed on Report', 'Days to Manufacture', 'Notes', 'Date Shown Completed', 'Actual Ship Date', 'Qty Shipped'],
			  colWidths: [300, 70, 70, 110, 110, 90, 90, 300, 90, 90],
			  rowHeaders: true,
			  headerTooltips: {
			  	columns: true,
			  	onlyTrimmed: true
			  },
			  filters: true,
			  dropdownMenu: true,
			});
		</script>

Thank you in advance!

Hey @jbishop

that’s a syntax error. Here’s what we have in the 2nd row

'AMOCO 1'
    9 x4 '4 TOGO SF CTS SGN(NO LEAF)||DWG BP1024SF_LDSV||FACE: BP184910||'

Where ‘AMOCO 1’ is the first value. Then there is something that is not a value (it is not provided as a string but it has x char, it also do not have a comma before and after).

Is that https://jsfiddle.net/nbqzr13s/ was the intension?

No I’m sorry…this is the actual value ‘AMOCO 1’9x4’4 TOGO SF CTS SGN(NO LEAF)||DWG BP1024SF_LDSV||FACE: BP184910||’ for the first cell in that row.

But 1’9x4’4 should appear that way. It references measurements…in this case feet. 1 foot 9 inches x 4 feet 4 inches.

A lot of the values going into the table will have single quotes and double quotes like that…is there some way to escape the values to keep the quotes and other possible special characters from affecting handsontable?

Then you need to use the escape character
src: https://www.w3schools.com/js/js_strings.asp

Updated demo https://jsfiddle.net/gj2sb8p5/

That is not something that we control, that is a rule of variable construction. Once you use single quotes for values you either use a double quotes inside or use escape characters.