I'm trying to use the function: insertHTML
As per manual: editor.insertHTML('TEXTO DE TESTE', true, true);
I created a button and put a jquery
suneditor.insertHTML('Text 1', true, true);
But when clicking the button it does not add the text. But if I click on the editor and then click on the button, the text is added.
What am I doing wrong?
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css">
<link href="http://suneditor.com/dist/css/suneditor.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/codemirror#5.49.0/lib/codemirror.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex#0.11.1/dist/katex.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<button id="text1">Text 1</button>
<button id="text2">Text 2</button>
<button id="text3">Text 3</button>
<textarea id="exampleOptions" style="width:100%; height:200px;">
Teste de Editor
</textarea>
<script src="http://suneditor.com/sample/js/common.js"></script>
<script src="http://suneditor.com/dist/suneditor.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/codemirror#5.49.0/lib/codemirror.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/codemirror#5.49.0/mode/htmlmixed/htmlmixed.js"></script>
<script src="https://cdn.jsdelivr.net/npm/codemirror#5.49.0/mode/xml/xml.js"></script>
<script src="https://cdn.jsdelivr.net/npm/codemirror#5.49.0/mode/css/css.js"></script>
<script src="https://cdn.jsdelivr.net/npm/katex#0.11.1/dist/katex.min.js"></script>
<script>
$(document).ready(function(){
$("#text1").click( function(){
suneditor.insertHTML('Text 1', true, true);
});
$("#text2").click( function(){
suneditor.insertHTML('Text 3', true, true);
});
$("#text3").click( function(){
suneditor.insertHTML('Text 2', true, true);
});
suneditor = SUNEDITOR.create('exampleOptions',{
font : [
'Arial',
'tahoma',
'Courier New,Courier'
],
fontSize : [
8, 10, 14, 18, 24, 36
],
colorList: [
['#ccc', '#dedede', 'OrangeRed', 'Orange', 'RoyalBlue', 'SaddleBrown'],
['SlateGray', 'BurlyWood', 'DeepPink', 'FireBrick', 'Gold', 'SeaGreen']
],
paragraphStyles: [
'spaced',
'neon',
{
name: 'Custom',
class: '__se__customClass'
}
],
textStyles: [
'translucent',
{
name: 'Emphasis',
style: '-webkit-text-emphasis: filled;',
tag: 'span'
}
],
width: '100%',
maxWidth: '600px',
minWidth: 400,
height : 'auto',
videoWidth : '80%',
youtubeQuery : 'autoplay=1&mute=1&enablejsapi=1',
imageWidth : 150,
popupDisplay: 'local',
resizingBar: false,
buttonList : [
[
I believe that insertHTML is working with the last cursor position. So if you don't focus the editor, last position of cursor is undefined and insertHTML will not work until you focus the editor. By the way i believe there is focus method that you can focus the editor then use insertHTML method. Documentation
editor.focus();
editor.insertHTML("...");
Related
I need to know how to apply css styles for a notify.js alert.
Here's my code -
$.notify({
message: "Alert!"
}, {
type: 'danger',
animate: {
enter: 'animated fadeInUp',
},
placement: {
from: "top",
align: "center"
},
offset: 20,
spacing: 10,
z_index: 1031,
});
I need to apply some styles for this.
$.notify({
message: "Alert!"
}, {
type: 'danger',
animate: {
enter: 'animated fadeInUp',
},
placement: {
from: "top",
align: "center"
},
offset: 20,
spacing: 10,
z_index: 1031,
style: 'addClassName'
});
then a structure like this will be constructed in html for notifiy
<div class="notifyjs-addClassName-base notifyjs-addClassNamesuccess">
<div class="clearfix">
<div class="title" data-notify-html="title">Would you like some Foo ?
</div>
<div class="buttons">
<button class="no">Cancel</button>
<button class="yes" data-notify-text="button">Confirm</button>
</div>
</div>
</div>
and thereafter you can create 1 css filr as per your need and add css making this .notifyjs-addClassName-base as the base class
.notifyjs-addClassName-base{
}
I use Kendo UI to create grids. I use opcion data-filterable to filter data.
I would like to change language from English to Polish.
How should I do it?
Below, you can find my script . I would like to exchange " Is equal to " on polish equivalent.
var viewModel;
viewModel = kendo.observable({
isVisible: true,
products: new kendo.data.DataSource({
schema: {
model: {
id: "ProductID",
fields: {
login: {type: "string"},
naz_druk: {type: "string"},
naz_wys: {type: "string"},
zabl: {type: "string"},
arch: {type: "string"},
ost_log: {type: "date"},
il_log: {type: "number"},
gen_zap: {type: "number"},
il_zap: {type: "number"}
}
}
},
batch: true,
data: [{
"login": "AGCDE",
"naz_druk": "Jan Kowalski",
"naz_wys": "Jan Kowalski",
"zabl": "TAK",
"arch": "NIE",
"ost_log": "12/12/2016",
"il_log": "5",
"gen_zap": "5",
"il_zap": "5"
},
{
"login": "bbbGCDE",
"naz_druk": "Jan Nowak",
"naz_wys": "Jan Nowak",
"zabl": "NIE",
"arch": "NIE",
"ost_log": "12/06/2016",
"il_log": "2",
"gen_zap": "2",
"il_zap": "2"
}]
})
});
kendo.bind($("#oknoGlowne"), viewModel);
meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<!--<link rel="stylesheet" type="text/css" href="format_cs.css">-->
<base href="http://demos.telerik.com/kendo-ui/grid/mvvm">
<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.1.412/styles/kendo.common.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.1.412/styles/kendo.uniform.min.css" />
<script src="//kendo.cdn.telerik.com/2016.1.412/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.1.412/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="../content/shared/styles/examples-offline.css">
<script src="../content/shared/js/console.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css">
<div>
<!-- Container glówne okno-->
<div id="oknoGlowne"
data-role="window"
data-title="Lista użytkowników"
data-bind="visible: isVisible"
data-width="800"
data-height="400"
style="padding:0; border: none;"
data-actions="[
'Pin',
'Minimize',
'Maximize',
'Close',
]"
>
<div data-role="splitter"
data-orientation="vertical"
data-panes="[{
collapsible: false,
resizable: false,
size: '30px'
},{
collapsible: false,
resizable: true
}]"
style="height: 100%; border: none;">
<!-- Główny div-->
<div>
<!-- Menu główne-->
<div class="menuGlowne"
data-role="menu"
data-resizable="true"
data-bind="events: { select: onMenuSelect }"
style="width: 100%; border: none;background-color: lightgray; ">
<li><input class="search"
style="width:150px;"
data-spinners="false"
placeholder="Rola"></li>
<li><input class="search"
style="width:150px;"
data-spinners="false"
placeholder="Loginid"></li>
<li data-menu-id="dodajUzytkownika"
data-title="Dodaj użytkownika"
data-role="tooltip"
data-auto-hide="true"
data-position="top">
<span class="fa fa-plus"></span></li>
<li data-menu-id="edycjauzytkownika"
data-title="Edytuj/uzupełnij dane użytkownika"
data-role="tooltip"
data-auto-hide="true"
data-position="top">
<span class="fa fa-pencil-square-o"></span></li>
</div>
<div>
<div data-role="grid"
data-editable="false"
data-sortable="true"
data-pageable='{
"previousNext": true,
"numeric": true,
"pageSizes": true,
"info": true
}'
data-resizable="true"
data-columns="[
{ 'field': 'login', 'width': 50, 'title' : 'Login'},
{ 'field': 'naz_druk','width': 50, 'title' : 'Nazwa drukowana' },
{ 'field': 'naz_wys','width': 50, 'title' : 'Nazwa wyświetlana' },
{ 'field': 'zabl','width': 20, 'title' : 'Zablokowany' },
{ 'field': 'arch','width': 20, 'title' : 'Zarchiwizowany' },
{ 'field': 'ost_log','width': 50, 'title' : 'Ostatnie logowanie','format': '{0:MM/dd/yyyy}' },
{ 'field': 'il_log','width': 20, 'title' : 'Ilość logowań' },
{ 'field': 'gen_zap','width': 20, 'title' : 'Wygenerowane zapytania' },
{ 'field': 'il_zap', 'width': 20,'title' : 'Ilość zapytań' },
]"
data-bind="source: products,
visible: isVisible,
events: {
save: onSave
}"
data-filterable="[
{ field: 'login', operator: 'startswith' },
{ field: 'naz_druk', operator: 'startswith' },
{ field: 'naz_wys', operator: 'startswith' },
{ field: 'zabl', operator: 'startswith' },
{ field: 'arch', operator: 'startswith' },
{ field: 'ost_log', operator: 'startswith' },
{ field: 'il_log', operator: 'startswith' },
{ field: 'gen_zap', operator: 'startswith' },
{ field: 'il_zap', extra: 'false', operator: 'number' },
]"
style="height: 100%; border: none;">
</div>
</div>
</div>
</div>
</div>
have you tried to search here?
http://docs.telerik.com/kendo-ui/framework/localization/overview
In general, you can do kendo.culture("en-US") to change it to English (change value for Polish iso code), but you also need to include the culture js file for the languages you support. If you want a hybrid (mainly english with Polish on the menu), you will have to manually set those messages yourself. You can do so with calls to override the messages directly like this:
kendo.ui.FilterCell.prototype.options.operators.string.eq = "Some Value"
I have a table with 4 columns. [ID,FIRSTNAME,LASTNAME,ADDRESS]. I am displaying the 3 cloumns[ID,FIRSTNAME,LASTNAME] on the kendogrid. What i am trying to do is on clicking the FIRSTNAME it should display the ADDRESS on a new window.But i am not getting it. I tried to get the link on the FIRSTNAME but dont know how to proceed later. i am new to this concept.Below is my code.Do i need to create a kendo grid for the Address or how it works.What i want is a hyperlink on ID to show ADDRESS.
Thanks.
Grid = $("#grid").kendoGrid({
dataSource:gridDS,
height: 450,
pageable: false,
sortable: true,
binding: true
columns: [
{
field: "ID",
title: "ID",
headerTemplate: '<span class="tbl-hdr">ID</span>',
attributes: {
style: "vertical-align: top; text-align: left; font-weight:bold; font-size: 12px"
},
width: 85
},
{
field: "FIRSTNAME",
title: "FIRSTNAME",
headerTemplate: '<span class="tbl-hdr">FIRSTNAME</span>',
template: '#=ADDRESS#',
attributes: {
style: "vertical-align: top; text-align: left; font-weight:bold; font-size: 12px"
},
width: 25
},
{
field: "LASTNAME",
title: "LASTNAME",
headerTemplate: '<span class="tbl-hdr">LASTNAME</span>',
attributes: {
style: "vertical-align: top; text-align: left; font-weight:bold; font-size: 12px"
},
width: 85
},
{
command: [
{
name: "destroy",
template: "<div class='k-button delete-btn'><span class='k-icon k-delete'></span></div>",
text: "remove"
},
{
text: "Edit",
template: "<div class='k-button edit-btn'><span class='k-icon k-edit'></span></div>",
},
],
width: 40,
attributes: {
style: "vertical-align: top; text-align: center;"
}
},
],
editable: "popup"
}).data('kendoGrid');
}
I think this is not a kendo issue, is pretty much about JS/jQuery. What I suggest is to bind an event on the grid to get all click events from that link in your template. Then, you can get the clicked dataItem with the row data of it.
.on("click", "a.name-link", function() {
var tr = $(this).closest("tr");
var dataItem = $("#grid").data("kendoGrid").dataItem(tr);
window.alert(dataItem.Address);
});
Working Demo
What is unclear is how you want to open a new window with the Address. What you mean:A fresh new browser tab/window or anything like a JS Popup inside your app?
If you want a new browser tab/window, you should pass the row id to it using window.open() and then in this window, you will have to hit the database again to show the information. Now, if want a javascript popup(e.g. Bootstrap's Modal) inside your app, you can use the previous retrieved dataItem to fill it. The information is already there.
I updated the code. You can click on firstName to view address.
If you want to go a little bit further, you can click on Address button to view address in pop-up window.
Sample at Telerik Kendo UI Dojo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Kendo UI Snippet</title>
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.common.min.css" />
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.rtl.min.css" />
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.silver.min.css" />
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.mobile.all.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.1.112/js/kendo.all.min.js"></script>
<style type="text/css">
a {
cursor: pointer;
text-decoration: underline;
}
.k-grid-update {
display: none;
}
</style>
</head>
<body>
<script id="row-template" type="text/x-kendo-tmpl">
<a onclick="display('#=address#')">#=firstName#</a>
</script>
<script id="popup-editor" type="text/x-kendo-template">
#=address#
</script>
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "id" },
{ field: "firstName", template: kendo.template($("#row-template").html()) },
{ field: "lastName" },
{ command: [{ name: "edit", text: { edit: "Address", cancel: "Close", update: "Close" } }]
}
],
dataSource: {
data: [
{ id: 1, firstName: "Jane", lastName: "Doe", address: "123 Street" },
{ id: 2, firstName: "John", lastName: "Doe", address: "456 Street" }
],
schema: {
model: { id: "id" }
}
},
editable: {
mode: "popup",
window: { title: 'Address' },
template: kendo.template($("#popup-editor").html())
}
});
function display(address) {
alert(address);
}
</script>
</body>
</html>
How could I set a horizontal title for X axis and a vertical title for axis Y in Kendo chart ?
For example , for this chart I want to set titles (Month and VISITORS) as in this image -
valueAxis:[{
title: {
text: "My Text X"
}
}],
title:{
text: "My Text Y",
position: "bottom"
}
Thanks for this, it was very helpful when solving my problem, which was similar. I edited the example accordingly: http://dojo.telerik.com/OBOZefEr/2 I've put the entire code snipped below, you're welcome to run it from here.
<!DOCTYPE html>
<html>
<head>
<base href="http://demos.telerik.com/kendo-ui/bar-charts/index">
<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.1.112/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.1.112/styles/kendo.material.min.css" />
<script src="//kendo.cdn.telerik.com/2016.1.112/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.1.112/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example">
<div class="demo-section k-content wide">
<div id="chart" style="background: center no-repeat url('../content/shared/styles/world-map.png');"></div>
</div>
<script>
function createChart() {
$("#chart").kendoChart({
title: {
text: "Site Visitors Stats \n /thousands/"
},
legend: {
visible: false
},
seriesDefaults: {
type: "bar"
},
series: [{
name: "Total Visits",
data: [56000, 63000, 74000, 91000, 117000, 138000]
}, {
name: "Unique visitors",
data: [52000, 34000, 23000, 48000, 67000, 83000]
}],
valueAxis: {
max: 140000,
line: {
visible: false
},
minorGridLines: {
visible: true
},
labels: {
rotation: "auto"
},
title: {
text: "VISITORS"
}
},
categoryAxis: {
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
majorGridLines: {
visible: false
},
title: {
text: "Month"
}
},
tooltip: {
visible: true,
template: "#= series.name #: #= value #"
}
});
}
$(document).ready(createChart);
$(document).bind("kendo:skinChange", createChart);
</script>
</div>
</body>
</html>
I am using jqxwidget. While integrating the widgets I have used jqxgrid , jqxwindow and jqxtabs
When I implement the jqxtabs I face the javascript error a.ownerDocument.defaultView
and my editor stops working.
How can I solve this issue?
I have added following code:
var initWidgets = function (tab) {
switch (tab) {
case 0:
initGrid();
break;
}
}
$('#jqxTabs').jqxTabs({ width: 'auto', height: 'auto'});
I have added my code to submit my form inside the function initGrid.
Have you tried to init the widgets within the jQWidgets Tabs initTabContent function? Example: jQWidgets Tabs Integration with UI Widgets
<!DOCTYPE html>
<html lang="en">
<head>
<title id='Description'>This demo shows how to integrate jqxTabs with other widgets.
</title>
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../scripts/demos.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxtabs.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxchart.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var initGrid = function () {
var source =
{
datatype: "csv",
datafields: [
{ name: 'Date' },
{ name: 'S&P 500' },
{ name: 'NASDAQ' }
],
url: '../sampledata/nasdaq_vs_sp500.txt'
};
var dataAdapter = new $.jqx.dataAdapter(source, { async: false, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } });
$("#jqxGrid").jqxGrid(
{
width: '100%',
height: '84%',
source: dataAdapter,
columns: [
{ text: 'Date', datafield: 'Date', cellsformat: 'd', width: 250 },
{ text: 'S&P 500', datafield: 'S&P 500', width: 150 },
{ text: 'NASDAQ', datafield: 'NASDAQ' }
]
});
}
var initChart = function () {
// prepare the data
var source =
{
datatype: "csv",
datafields: [
{ name: 'Date' },
{ name: 'S&P 500' },
{ name: 'NASDAQ' }
],
url: '../sampledata/nasdaq_vs_sp500.txt'
};
var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } });
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// prepare jqxChart settings
var settings = {
title: "U.S. Stock Market Index Performance (2011)",
description: "NASDAQ Composite compared to S&P 500",
enableAnimations: true,
showLegend: true,
padding: { left: 10, top: 5, right: 10, bottom: 5 },
titlePadding: { left: 90, top: 0, right: 0, bottom: 10 },
source: dataAdapter,
categoryAxis:
{
dataField: 'Date',
formatFunction: function (value) {
return months[value.getMonth()];
},
toolTipFormatFunction: function (value) {
return value.getDate() + '-' + months[value.getMonth()];
},
type: 'date',
baseUnit: 'month',
showTickMarks: true,
tickMarksInterval: 1,
tickMarksColor: '#888888',
unitInterval: 1,
showGridLines: true,
gridLinesInterval: 3,
gridLinesColor: '#888888',
valuesOnTicks: false
},
colorScheme: 'scheme04',
seriesGroups:
[
{
type: 'line',
valueAxis:
{
displayValueAxis: true,
description: 'Daily Closing Price',
axisSize: 'auto',
tickMarksColor: '#888888'
},
series: [
{ dataField: 'S&P 500', displayText: 'S&P 500' },
{ dataField: 'NASDAQ', displayText: 'NASDAQ' }
]
}
]
};
// setup the chart
$('#jqxChart').jqxChart(settings);
}
// init widgets.
var initWidgets = function (tab) {
switch (tab) {
case 0:
initGrid();
break;
case 1:
initChart();
break;
}
}
$('#jqxTabs').jqxTabs({ width: 600, height: 560, initTabContent: initWidgets });
});
</script>
</head>
<body class='default'>
<div id='jqxWidget'>
<div id='jqxTabs'>
<ul>
<li style="margin-left: 30px;">
<div style="height: 20px; margin-top: 5px;">
<div style="float: left;">
<img width="16" height="16" src="../../images/catalogicon.png" />
</div>
<div style="margin-left: 4px; vertical-align: middle; text-align: center; float: left;">
US Indexes</div>
</div>
</li>
<li>
<div style="height: 20px; margin-top: 5px;">
<div style="float: left;">
<img width="16" height="16" src="../../images/pieicon.png" />
</div>
<div style="margin-left: 4px; vertical-align: middle; text-align: center; float: left;">
NASDAQ compared to S&P 500</div>
</div>
</li>
</ul>
<div style="overflow: hidden;">
<div id="jqxGrid">
</div>
<div style="margin-top: 10px; height: 15%;">
The S&P 500 index finished 2011 less than a point away from where it ended 2010
-- 0.04 points down to be exact. That's the smallest annual change in history. At
its peak in April, the S&P had climbed more than 8%. But by October, at the lowest
levels of the year, it was down more than 12%. The Nasdaq, meanwhile, lost 1.8%
for the year.</div>
</div>
<div style="overflow: hidden;">
<div id='jqxChart' style="width: 100%; height: 100%">
</div>
</div>
</div>
</div>
</body>
</html>