Note that there are some explanatory texts on larger screens.

plurals
  1. POEscaping html special chars in a datagrid column
    primarykey
    data
    text
    <p>i have a datagrid (6 columns) which displays strings from the database. I am trying to use a labelfunction to escape html special characters in the string (like &amp;apos,&amp;amp etc).</p> <p>I found this on the net :</p> <pre><code>protected function makeSpecialChars(item:Object,dgName:DataGridColumn):String { var s:String = agentName.dataField; var v:String = item.s; return new XMLDocument(v).firstChild.nodeValue; } </code></pre> <p>However when i do this I get the error : Cannot access a property or method of a null object reference.</p> <p>This works fine when i change the above code like this :</p> <pre><code>protected function makeSpecialChars(item:Object,agentName:DataGridColumn):String { return new XMLDocument(item.computer_name).firstChild.nodeValue; } </code></pre> <p>where computer_name is the datafield of this datagrid column. </p> <p>Posting Datagrid code :</p> <pre><code>&lt;components:DoubleClickDataGrid xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="components.*" width="100%" height="100%" editable="true" focusColor="#CEDA9B" rollOverColor="#CEDA9B" selectionColor="#84A207" dataProvider="{invList}" creationComplete="doubleclickdatagrid1_creationCompleteHandler(event)" itemEditEnd="handleInventoryEdit(event)"&gt; &lt;components:columns&gt; &lt;mx:DataGridColumn width="120" dataField="computer_name" headerText="Computer Name" textAlign="center" labelFunction="makeSpecialChars"/&gt; &lt;mx:DataGridColumn dataField="path" headerText="Path" textAlign="center" labelFunction="makeSpecialChars"/&gt; &lt;mx:DataGridColumn width="110" dataField="computer_type" textAlign="center" headerText="Computer Type" /&gt; &lt;mx:DataGridColumn width="180" dataField="username" headerText="Username" textAlign="center" /&gt; &lt;mx:DataGridColumn width="90" dataField="ip_address" headerText="IP Address" textAlign="center" /&gt; &lt;mx:DataGridColumn width="130" dataField="mac_address" headerText="MAC Address" textAlign="center" /&gt; &lt;mx:DataGridColumn width="180" dataField="computer_model" headerText="Computer Model" textAlign="center" /&gt; &lt;mx:DataGridColumn width="70" editable="false" headerText="Actions" textAlign="center" itemRenderer="renderers.ActionRenderer" /&gt; &lt;/components:columns&gt; </code></pre> <p></p> <p>This much is working fine as of now (applied labelfunction to only 2 columns).. But I want to apply the label function to all the columns ...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload