Having trouble getting help?
Contact Support
Contact Support
Right-To-Left support in Syncfusion JavaScript Controls
10 May 20233 minutes to read
Right To Left (RTL) can be enabled for Syncfusion JavaScript UI controls by calling enableRtl
with
true
. This will render all the Syncfusion JavaScript controls in right to left direction. Find the code snippet
for this below.
// Enables Right to left alignment for all controls
ej.base.enableRtl(true);
var rtlListObj = new ej.lists.ListView({
dataSource: data,
headerTitle: 'کاریں',
showHeader: true,
height: '350px'
});
rtlListObj.appendTo('#listview');
<!DOCTYPE html><html><head>
<meta charset="UTF-8">
<link href="https://cdn.syncfusion.com/ej2/28.2.3/ej2-lists/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/28.2.3/dist/ej2.min.js" type="text/javascript"></script>
<script src="es5-datasource.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="listview"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Enable RTL to individual control
To enable the RTL to an individual control, set the enableRtl
property directly in its model options. For illustration, the enableRtl
is added to the ListView control in following code snippet.
var rtlListObj = new ej.lists.ListView({
dataSource: data,
enableRtl: true,
headerTitle: 'کاریں',
showHeader: true,
height: '350px'
});
rtlListObj.appendTo('#listview');
<!DOCTYPE html><html><head>
<link href="https://cdn.syncfusion.com/ej2/28.2.3/ej2-lists/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/28.2.3/dist/ej2.min.js" type="text/javascript"></script>
<script src="es5-datasource.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="listview"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>