UI Widgets TextArea

A widget used to display and edit multi-line text.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/text_area
TextArea interactive configuration
Copy code
$("#textarea").dxTextArea({
});

The TextArea widget is a multi-line resizable text field.

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxTextArea jQuery plug-in.

    HTML
    <div id="textArea"></div>
    JavaScript
    $("#textArea").dxTextArea({
        value: 'Text displayed by the widget',
        maxLength: 300,
        height: 400
    });
  • Knockout
    Add a div element and apply the dxTextArea binding to this element.

    HTML
    <div data-bind="dxTextArea: {
        value: 'Text displayed by the widget',
        maxLength: 300,
        height: 400
    }"></div>
  • AngularJS
    Add a div element and apply the dx-text-area directive to this element.

    HTML
    <div dx-text-area="{
        value: 'Text displayed by the widget',
        maxLength: 300,
        height: 400
    }"></div>

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the Installation article.

You can find detailed information on the principles of working with the widget in the dxTextArea section of the Editor Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController" style="height: 100%;">
    <div ng-model="text" dx-text-area="{
        height: 300
    }"></div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.text = "";
    $.ajax({
        type: "POST",
        url: "/LoremService.asmx/LoremIpsum",
        data: JSON.stringify({ count: 1 }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            $scope.text = data.d[0];
        }
    });
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
body{
    text-align: center;
}
.dx-textarea{
    margin: 10px;
}
<div data-bind="dxTextArea: { value: text, height: 300 }"></div>
var myViewModel = {
    text: ko.observable("")
}
ko.applyBindings(myViewModel);
$.ajax({
    type: "POST",
    url: "/LoremService.asmx/LoremIpsum",
    data: JSON.stringify({ count: 1 }),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
        myViewModel.text(data.d[0]);
    }
});
body{
    text-align: center;
}
.dx-textarea{
    margin: 10px;
}
<div id="myTextArea"></div>
$("#myTextArea").dxTextArea({
    height: 300
});
$.ajax({
    type: "POST",
    url: "/LoremService.asmx/LoremIpsum",
    data: JSON.stringify({ count: 1 }),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
        $("#myTextArea").dxTextArea("instance").option("text", data.d[0]);
        $("#myTextArea").dxTextArea("instance").repaint();
    }
});
body{
    text-align: center;
}
.dx-textarea{
    margin: 10px;
}

Configuration

An object defining configuration options for the TextArea widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.