|
| 1 | +--- |
| 2 | +title: Stack static notifications to the left or right |
| 3 | +page_title: Stack static notifications to the left or right |
| 4 | +description: Stack static notifications to the left or right |
| 5 | +--- |
| 6 | + |
| 7 | +# Stack static notifications to the left or right |
| 8 | + |
| 9 | +The following demo shows how to stack static notifications to the left or to the right |
| 10 | + |
| 11 | +#### Example |
| 12 | + |
| 13 | +```html |
| 14 | +<style> |
| 15 | +
|
| 16 | + .notification-container |
| 17 | + { |
| 18 | + min-height: 2.6em; |
| 19 | + padding: .3em .6em; |
| 20 | + overflow: auto; |
| 21 | + } |
| 22 | +
|
| 23 | + #ntfLeft |
| 24 | + { |
| 25 | + text-align: right; |
| 26 | + } |
| 27 | +
|
| 28 | + .notification-container .k-notification |
| 29 | + { |
| 30 | + padding: .3em .6em; |
| 31 | + } |
| 32 | +
|
| 33 | +</style> |
| 34 | + |
| 35 | +<script id="my-template" type="text/x-kendo-template"> |
| 36 | + <div class="my-container"> |
| 37 | + #= message # |
| 38 | + </div> |
| 39 | +</script> |
| 40 | + |
| 41 | +<p><button id="buttonRight" class="k-button">Stack to the right</button></p> |
| 42 | +<div id="ntfRight" class="k-block notification-container"></div> |
| 43 | + |
| 44 | +<p><button id="buttonLeft" class="k-button">Stack to the left</button></p> |
| 45 | +<div id="ntfLeft" class="k-block notification-container"></div> |
| 46 | + |
| 47 | +<script> |
| 48 | +
|
| 49 | +$(function() { |
| 50 | + var options = { |
| 51 | + stacking: "down", |
| 52 | + autoHideAfter: 0, |
| 53 | + templates: [{ |
| 54 | + type: "my-type", |
| 55 | + template: $("#my-template").html() |
| 56 | + }], |
| 57 | + show: function(e) { |
| 58 | + e.element.css("display", "inline-block"); |
| 59 | + } |
| 60 | + }; |
| 61 | + var ntfRight = $("#ntfRight").kendoNotification($.extend(options, {stacking: "down", appendTo: "#ntfRight"})).data("kendoNotification"); |
| 62 | + var ntfLeft = $("#ntfLeft").kendoNotification($.extend(options, {stacking: "up", appendTo: "#ntfLeft"})).data("kendoNotification"); |
| 63 | + |
| 64 | + $(".k-button").click(function (e) { |
| 65 | + var notificationWidget = $(e.target).is("#buttonLeft") ? ntfLeft : ntfRight; |
| 66 | + var d = new Date(); |
| 67 | + notificationWidget.show({ |
| 68 | + message: kendo.toString(d, 'HH:MM:ss.') + kendo.toString(d.getMilliseconds(), "000") |
| 69 | + }, "my-type"); |
| 70 | +
|
| 71 | + var container = $(notificationWidget.options.appendTo); |
| 72 | + container.scrollTop(container[0].scrollHeight); |
| 73 | + }); |
| 74 | +
|
| 75 | + |
| 76 | +}); |
| 77 | +
|
| 78 | +</script> |
| 79 | +``` |
0 commit comments