igGrid multilines cell value
by georgianastasov
HTML
<script src="https://igniteui.com/js/modernizr.min.js"></script>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<script src="https://cdn-na.infragistics.com/igniteui/latest/js/infragistics.core.js"></script>
<script src="https://cdn-na.infragistics.com/igniteui/latest/js/infragistics.lob.js"></script>
<script src="https://igniteui.com/data-files/adventureworks.min.js"></script>
<link href="https://cdn-na.infragistics.com/igniteui/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet"></link>
<link href="https://cdn-na.infragistics.com/igniteui/latest/css/structure/infragistics.css" rel="stylesheet"></link>
<div id="grid-mrl"></div>
JavaScript
$(function () {
var data = [
{ ID: 1, Name: "John Doe", Description: "This is a simple\nmultiline description" },
{ ID: 2, Name: "Jane Smith", Description: "Another example\nwith two lines" },
{ ID: 3, Name: "Alice Johnson", Description: "Multiline text\nfor testing\nthird record" }
];
$('#grid-mrl').igGrid({
width: '100%',
height: '400px',
autoGenerateColumns: false,
primaryKey: 'ID',
columns: [
{ headerText: "ID", key: "ID", dataType: "number", width: "100px" },
{ headerText: "Name", key: "Name", dataType: "string", width: "250px" },
{
headerText: "Description",
key: "Description",
dataType: "string",
width: "250px",
formatter: function (val) {
return val.replace(/\n/g, '<br/>');
},
unencoded: true
}
],
dataSource: data,
features: [
{
name: 'Updating',
enableAddRow: false,
editMode: 'cell',
columnSettings: [
{ columnKey: "Name", editorType: "text" },
{
columnKey: 'Description',
editorType: 'text', // Use the custom editor type
editorOptions: {
textMode: 'multiline' // Enable multiline input
}
}
],
}
]
});
});