Reputation: 431
How to add the following custom div structure to the dxDataGrid cell (or cellTemplate):
<div class="some_class_1" id="some_id">
<div class="some_class_2">some_text</div>
</div>.
I must to have access to any of these divs by it's unique id ('some_id' in an example).
I try this:
cellTemplate: function (container) {
$('<div/>').attr('id', 'some_id').addClass('some_class_1')
.add("div").addClass('some_class_2').text('some_text')
.appendTo(container);
}
...that's not work.
It is good to see snippet. Thanx in advance.
Upvotes: 1
Views: 534
Reputation: 431
Jai solution works. And this alternative works fine too:
cellTemplate: function (container) {
$("<div>")
.addClass('some_class_2')
.text('some_text')
.appendTo($('<div>')
.attr('id', 'some_id')
.addClass('some_class_1')
.appendTo(container));
}
Upvotes: 0
Reputation: 74738
You have to put new element and return it:
cellTemplate: function (container) {
return $('<div/>').attr('id', 'some_id'+$(container).index()).addClass('some_class_1')
.append($("<div>").addClass('some_class_2').text('some_text'))
.appendTo(container);
}
Upvotes: 1