UI Controls
Auto Complete
Add auto complete to the web control
See: AutoComplete
Add AutoComplete
In html file add code:
<input id="autocomplete" />
In js file add code:
var autoComplete = new KQ.ui.AutoComplete('autocomplete', {}); var data = [ "America", "Australia", "China", "France", "Germany", "Greece", "Iceland", "Japan", "Korea", "Netherlands", "Poland", "Russia", "Switzerland", "England", ]; autoComplete.setDataSource(data);
Result:
Button
Button web control
See: Button
Add Button
In html file add code:
<button id="button" type="button">My Button</button>
In js file add code:
var button = new KQ.ui.Button('button', {}); button.enable(false);
Result:
Chart
Chart web control
See: Chart
Pie Chart Basic Usage
In html file add code:
<div id="chart" style="width: 600px; height: 500px;"></div>
In js file add code:
var data = [{ categoryField: "Asia", value: 30.8, color: "#9de219" },{ categoryField: "Europe", value: 21.1, color: "#90cc38" },{ categoryField: "Latin America", value: 16.3, color: "#068c35" },{ categoryField: "Africa", value: 17.6, color: "#006634" },{ categoryField: "Middle East", value: 9.2, color: "#004d38" },{ categoryField: "North America", value: 4.6, color: "#033939" }]; var chart = new KQ.ui.Chart('chart', { dataSource: { data: data, }, title: { position: "top", text: "Share of Internet Population Growth", }, legend: { visible: true, position: "left", }, series: [{ type: "pie", // pie chart field: "value", categoryField: "categoryField", labels: { visible: true, background: "transparent", template: "#= category #: \n #= value#%", } }], tooltip: { visible: true, template: "#= category #-#= value #%", }, });
Result:
Horizontal Bar Chart
In html file add code:
<div id="chart" style="width: 600px; height: 500px;"></div>
In js file add code:
var data = [{ categoryField: "Asia", value: 30.8, color: "#9de219" },{ categoryField: "Europe", value: 21.1, color: "#90cc38" },{ categoryField: "Latin America", value: 16.3, color: "#068c35" },{ categoryField: "Africa", value: 17.6, color: "#006634" },{ categoryField: "Middle East", value: 9.2, color: "#004d38" },{ categoryField: "North America", value: 4.6, color: "#033939" }]; var chart = new KQ.ui.Chart('chart', { dataSource: { data: data, }, title: { position: "top", text: "Share of Internet Population Growth", }, legend: { visible: true, position: "left", }, series: [{ type: "bar", // bar chart(horizontal) field: "value", categoryField: "categoryField", }], });
Result:
Vertical Bar Chart
In html file add code:
<div id="chart" style="width: 600px; height: 500px;"></div>
In js file add code:
var data = [{ categoryField: "Asia", value: 30.8, color: "#9de219" },{ categoryField: "Europe", value: 21.1, color: "#90cc38" },{ categoryField: "Latin America", value: 16.3, color: "#068c35" },{ categoryField: "Africa", value: 17.6, color: "#006634" },{ categoryField: "Middle East", value: 9.2, color: "#004d38" },{ categoryField: "North America", value: 4.6, color: "#033939" }]; var chart = new KQ.ui.Chart('chart', { dataSource: { data: data, }, title: { position: "top", text: "Share of Internet Population Growth", }, legend: { visible: true, position: "left", }, series: [{ // type: "bar", // not set type is bar chart(vertical) field: "value", categoryField: "categoryField", }], });
Result:
Show Additional Field
In html file add code:
<div id="chart" style="width: 600px; height: 500px;"></div>
In js file add code:
var data = [{ categoryField: "Asia", value: 100, ratio: "50%", color: "#56a36c", },{ categoryField: "Europe", value: 100, ratio: "50%", color: "#2e68aa", }]; var chart = new KQ.ui.Chart('chart', { dataSource: { data: data, }, title: { position: "top", text: "Share of Internet Population Growth", }, legend: { visible: true, position: "left", }, series: [{ type: "pie", // pie chart field: "value", categoryField: "categoryField", labels: { visible: true, background: "transparent", template: "#= category #: \n value: #= data.dataItem.value ## ratio: #= data.dataItem.ratio #", } }], });
Result:
Checkbox
Checkbox web control
See: Checkbox
Add Checkbox
In html file add code:
<div id="checkbox"></div>
In js file add code:
var checkbox = new KQ.ui.Checkbox('checkbox', {label: 'this is a checkbox'});
Result:
Checked and Unchecked
In html file add code:
<div id="checkbox1"></div> <div id="checkbox2"></div>
In js file add code:
var checkbox1 = new KQ.ui.Checkbox('checkbox1', {label: 'the status is checked'}); var checkbox2 = new KQ.ui.Checkbox('checkbox2', {label: 'the status is unchecked'}); checkbox1.checked(true); checkbox2.checked(false);
Result:
Enabled or Disabled
In html file add code:
<div id="checkbox1"></div> <div id="checkbox2"></div>
In js file add code:
var checkbox1 = new KQ.ui.Checkbox('checkbox1', {label: 'the status is enabled'}); var checkbox2 = new KQ.ui.Checkbox('checkbox2', {label: 'the status is disabled'}); checkbox1.enable(true); checkbox2.enable(false);
Result:
DropdownList
DropdownList web control
See: DropdownList
Add DropdownList
In html file add code:
<input id="dropdownlist" />
In js file add code:
var dropdownlist = new KQ.ui.DropdownList('dropdownlist', {}); dropdownlist.setDataSource(['A', 'B', 'C']);
Result:
Grid
Grid web control
See: Grid
Add Grid Control
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age", width: 100}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], });
Result:
HeaderAttributes
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ { field: "name", title: "The Name", attributes: { "class": "name-cell", style: "text-align: left", }, headerAttributes: { "class": "name-header", style: "text-align: left", }, }, { field: "age", title: "The Age", width: 100, attributes: { "class": "name-cell", style: "text-align: center", }, headerAttributes: { "class": "name-header", style: "text-align: center", }, }, { field: "sex", title: "The Sex", attributes: { "class": "name-cell", style: "text-align: right", }, headerAttributes: { "class": "name-header", style: "text-align: right", }, }, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], });
Result:
Height and Scrollable
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age", width: 100}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], height: 80, scrollable: true, });
Result:
Selectable
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.TreeList('grid', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age", width: 100}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], selectable: true, });
Result:
Column's Width
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ {field: "name", title: "The Name", width: 200}, {field: "age", title: "The Age", width: 200}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], });
Result:
Pageable
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ {field: "name", title: "The Name", width: 200}, {field: "age", title: "The Age", width: 200}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], pageable: { pageSize: 2, pageSizes: [1, 2, 4, "all"], refresh: true, }, });
Result:
Messages Display
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ {field: "name", title: "The Name", width: 200}, {field: "age", title: "The Age", width: 200}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], pageable: { pageSize: 2, messages: { previous: "previous page", next: "next page", }, }, });
Result:
Select and ClearSelection
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ {field: "name", title: "The Name", width: 200}, {field: "age", title: "The Age", width: 200}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], selectable: "multiple, row", }); // select the first table row grid.select("tr:eq(0)"); grid.clearSelection();
DataItem
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ {field: "name", title: "The Name", width: 200}, {field: "age", title: "The Age", width: 200}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], selectable: "multiple, row", }); var data = grid.dataItem("tbody>tr:eq(1)"); console.log("name: " + data.name + " " + "age: " + data.age + " " + "sex: " + data.sex); // displays "name: John Doe age: 19 sex: Male"
Change Event
In html file add code:
<div id="grid"></div>
In js file add code:
var grid = new KQ.ui.Grid('grid', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age"}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], selectable: "multiple, row", change: function(e) { var selectedRows = this.select(); console.log(selectedRows.length); var selectedDataItems = [] for (var i = 0; i < selectedRows.length; i++) { var dataItem = this.dataItem(selectedRows[i]); selectedDataItems.push(dataItem); // selectedDataItems contains all selected data items } }, });
ListView
ListView web control
See: ListView
Add ListView
In html file add code:
<div id="listView"></div>
In js file add code:
var listView = new KQ.ui.ListView('listView', {}); listView.setDataSource([{name: 'London'}, {name: 'England'}, {name: 'Liverpool'}, {name: 'Belfast'}, {name: 'Sydney'}, {name: 'Leeds'}]); listView.selectFirstItem(); // Selects first list view item var select_item = listView.dataItem(listView.select()); // Get select item var select_item_name = select_item.name; console.log(select_item_name);
Result:
MaskedTextBox
MaskedTextBox web control
See: MaskedTextBox
Add MaskedTextBox
In html file add code:
<input id="maskedtextbox" />
In js file add code:
var maskedtextbox = new KQ.ui.MaskedTextBox('maskedtextbox', {}); maskedtextbox.value("Enter value...");
Result:
PanelBar
PanelBar web control
See: PanelBar
Basic Usage
In css file add code:
#panelbar{ margin: 10px; width: 300px; }
In html file add code:
<div id="panelbar"></div>
In js file add code:
var panelbar = new KQ.ui.PanelBar('panelbar', { dataSource: [ { text: "Baseball", imageUrl: "./icons/baseball.png", items: [ {text: "Top News", imageUrl: "./icons/star.png"}, {text: "Photo Galleries", imageUrl: "./icons/photo.png"}, {text: "Videos Records", imageUrl: "./icons/video.png"}, {text: "Radio Records", imageUrl: "./icons/speaker.png"} ] }, { text: "Golf", imageUrl: "./icons/golf.png", items: [ {text: "Top News", imageUrl: "./icons/star.png"}, {text: "Photo Galleries", imageUrl: "./icons/photo.png"}, {text: "Videos Records", imageUrl: "./icons/video.png"}, {text: "Radio Records", imageUrl: "./icons/speaker.png"} ] }, { text: "Swimming", imageUrl: "./icons/swimming.png", items: [ {text: "Top News", imageUrl: "./icons/star.png"}, {text: "Photo Galleries", imageUrl: "./icons/photo.png"} ] }, { text: "Snowboarding", imageUrl: "./icons/snowboarding.png", items: [ {text: "Photo Galleries", imageUrl: "./icons/photo.png"}, {text: "Videos Records", imageUrl: "./icons/video.png"} ] } ], });
Result:
Template Usage
In css file add code:
#panelbar{ margin: 10px; width: 300px; }
In html file add code:
<div id="panelbar"></div>
In js file add code:
var panelbar = new KQ.ui.PanelBar('panelbar', { template: "#= item.text ## (#= item.inStock #)", dataSource: [ { text: "foo", inStock: 7, items: [ { text: "bar", inStock: 2 }, { text: "baz", inStock: 5 } ] } ] });
Result:
Select Event
In html file add code:
<div id="panelbar"></div>
In js file add code:
var panelbar = new KQ.ui.PanelBar('panelbar', { template: "#= item.text ## (#= item.inStock #)", dataSource: [ { text: "foo", inStock: 7, items: [ { text: "bar", inStock: 2 }, { text: "baz", inStock: 5 } ],} ], select: function(e){ var dataItem = panelbar.dataItem(e.item); // printf: item info: (text: bar, inStock: 2) console.log('item info: ' + '(text: '+ dataItem.text + ', inStock: ' + dataItem.inStock + ')'); }, });
RadioButton
RadioButton web control
See: RadioButton
Add Radio Button
In html file add code:
<div id="radiobutton"></div>
In js file add code:
var radiobutton = new KQ.ui.RadioButton('radiobutton', {label: 'this is a radiobutton'});
Result:
Checked and Unchecked
In html file add code:
<div id="radiobutton1"></div> <div id="radiobutton2"></div>
In js file add code:
var radiobutton1 = new KQ.ui.RadioButton('radiobutton1', {label: 'the status is checked'}); var radiobutton2 = new KQ.ui.RadioButton('radiobutton2', {label: 'the status is unchecked'}); radiobutton1.checked(true); radiobutton2.checked(false);
Result:
Enabled or Disabled
In html file add code:
<div id="radiobutton1"></div> <div id="radiobutton2"></div>
In js file add code:
var radiobutton1 = new KQ.ui.RadioButton('radiobutton1', {label: 'the status is enabled'}); var radiobutton2 = new KQ.ui.RadioButton('radiobutton2', {label: 'the status is disabled'}); radiobutton1.enable(true); radiobutton2.enable(false);
Result:
TabStrip
TabStrip web control
See: TabStrip
Basic Usage
In html file add code:
<div id="tabstrip"> <ul> <li class="k-state-active"> Paris </li> <li> New York </li> <li> London </li> <li> Moscow </li> </ul> <div> <span class="rainy"> </span> <div class="weather"> <h2>17<span>ºC</span></h2> <p>Rainy weather in Paris.</p> </div> </div> <div> <span class="sunny"> </span> <div class="weather"> <h2>29<span>ºC</span></h2> <p>Sunny weather in New York.</p> </div> </div> <div> <span class="sunny"> </span> <div class="weather"> <h2>21<span>ºC</span></h2> <p>Sunny weather in London.</p> </div> </div> <div> <span class="cloudy"> </span> <div class="weather"> <h2>16<span>ºC</span></h2> <p>Cloudy weather in Moscow.</p> </div> </div> </div>
In css file add code:
.sunny, .cloudy, .rainy { display: block; margin: 30px auto 10px; width: 128px; height: 128px; background: url('weather.png') transparent no-repeat 0 0; } .cloudy{ background-position: -128px 0; } .rainy{ background-position: -256px 0; } .weather { margin: 0 auto 30px; text-align: center; } #tabstrip h2 { font-weight: lighter; font-size: 5em; line-height: 1; padding: 0 0 0 30px; margin: 0; } #tabstrip h2 span { background: none; padding-left: 5px; font-size: .3em; vertical-align: top; } #tabstrip p { margin: 0; padding: 0; }
In js file add code:
var tabstrip = new KQ.ui.TabStrip('tabstrip', {});
Result:
Add Image to Tabs
In html file add code::
<div id="tabstrip"></div>
In js file add code::
var tabstrip = new KQ.ui.TabStrip('tabstrip', { dataTextField: "text", dataImageUrlField: "imageUrl", dataContentField: "content", dataSource: [ { text: "Baseball", imageUrl: "baseball.png", content: "Baseball is a bat-and-ball sport played between two teams of nine players each. The aim is to score runs by hitting a thrown ball with a bat and touching a series of four bases arranged at the corners of a ninety-foot diamond. Players on the batting team take turns hitting against the pitcher of the fielding team, which tries to stop them from scoring runs by getting hitters out in any of several ways. A player on the batting team can stop at any of the bases and later advance via a teammate's hit or other means. The teams switch between batting and fielding whenever the fielding team records three outs. One turn at bat for each team constitutes an inning and nine innings make up a professional game. The team with the most runs at the end of the game wins." }, { text: "Golf", imageUrl: "golf.png", content: "Golf is a precision club and ball sport, in which competing players (or golfers) use many types of clubs to hit balls into a series of holes on a golf course using the fewest number of strokes. It is one of the few ball games that does not require a standardized playing area. Instead, the game is played on golf courses, each of which features a unique design, although courses typically consist of either nine or 18 holes. Golf is defined, in the rules of golf, as playing a ball with a club from the teeing ground into the hole by a stroke or successive strokes in accordance with the Rules." }, { text: "Swimming", imageUrl: "swimming.png", content: "Swimming has been recorded since prehistoric times; the earliest recording of swimming dates back to Stone Age paintings from around 7,000 years ago. Written references date from 2000 BC. Some of the earliest references to swimming include the Gilgamesh, the Iliad, the Odyssey, the Bible, Beowulf, and other sagas. In 1578, Nikolaus Wynmann, a German professor of languages, wrote the first swimming book, The Swimmer or A Dialogue on the Art of Swimming (Der Schwimmer oder ein Zwiegespräch über die Schwimmkunst). Competitive swimming in Europe started around 1800, mostly using breaststroke." } ] }); tabstrip.select(0);
Result:
TextArea
TextArea web mark
See: TextArea
Add TextArea
In html file add code:
<textarea id="myid">default-content</textarea>
In js file add code:
var textarea = new KQ.ui.TextArea('myid'); textarea.value("my content"); //change the contont to "my content" console.log(textarea.value()); //print "my content"
Result:
TreeList
TreeList web control
See: TreeList
Add TreeList Control
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age", width: 100}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], });
Result:
HeaderAttributes
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ { field: "name", title: "The Name", attributes: { "class": "name-cell", style: "text-align: left", }, headerAttributes: { "class": "name-header", style: "text-align: left", }, }, { field: "age", title: "The Age", width: 100, attributes: { "class": "name-cell", style: "text-align: center", }, headerAttributes: { "class": "name-header", style: "text-align: center", }, }, { field: "sex", title: "The Sex", attributes: { "class": "name-cell", style: "text-align: right", }, headerAttributes: { "class": "name-header", style: "text-align: right", }, }, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], });
Result:
Height and Scrollable
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age", width: 100}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], height: 80, scrollable: true, });
Result:
Selectable
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age", width: 100}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], selectable: true, });
Result:
Expandable
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ {field: "name", title: "The Name", expandable: true}, {field: "age", title: "The Age"}, {field: "sex", title: "The Sex"}, ], dataSource: [ {id: 1, parentId: null, name: "Jane Doe", age: 18, sex: "Male"}, {id: 2, parentId: 1, name: "John Doe", age: 19, sex: "Male"}, {id: 3, parentId: 1, name: "Eric Brown", age: 20, sex: "Female"}, {id: 4, parentId: 1, name: "George Doe", age: 21, sex: "Female"}, ], });
Result:
Row or Cell Select
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age"}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], selectable: "cell", }); treelist.select($("#treelist td:eq(0)"));
Result:
Expands The Row
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ {field: "name", title: "The Name", expandable: true}, {field: "age", title: "The Age"}, {field: "sex", title: "The Sex"}, ], dataSource: [ {id: 1, parentId: null, name: "Jane Doe", age: 18, sex: "Male"}, {id: 2, parentId: 1, name: "John Doe", age: 19, sex: "Male"}, {id: 3, parentId: 1, name: "Eric Brown", age: 20, sex: "Female"}, {id: 4, parentId: 1, name: "George Doe", age: 21, sex: "Female"}, ], }); treelist.expand($("#treelist tbody>tr:eq(0)"));
Result:
Returns The Data Item
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ {field: "name", title: "The Name", expandable: true}, {field: "age", title: "The Age"}, {field: "sex", title: "The Sex"}, ], dataSource: [ {id: 1, parentId: null, name: "Jane Doe", age: 18, sex: "Male"}, {id: 2, parentId: 1, name: "John Doe", age: 19, sex: "Male"}, {id: 3, parentId: 1, name: "Eric Brown", age: 20, sex: "Female"}, {id: 4, parentId: 1, name: "George Doe", age: 21, sex: "Female"}, ], }); var data = treelist.dataItem("tbody>tr:eq(1)"); console.log("name: " + data.name + " " + "age: " + data.age + " " + "sex: " + data.sex); // displays "name: John Doe age: 19 sex: Male"
Change Event
In html file add code:
<div id="treelist"></div>
In js file add code:
var treelist = new KQ.ui.TreeList('treelist', { columns: [ {field: "name", title: "The Name"}, {field: "age", title: "The Age"}, {field: "sex", title: "The Sex"}, ], dataSource: [ {name: "Jane Doe", age: 18, sex: "Male"}, {name: "John Doe", age: 19, sex: "Male"}, {name: "Eric Brown", age: 20, sex: "Female"}, {name: "George Doe", age: 21, sex: "Female"}, ], selectable: "multiple, row", change: function(e) { var selectedRows = this.select(); console.log(selectedRows.length); var selectedDataItems = [] for (var i = 0; i < selectedRows.length; i++) { var dataItem = this.dataItem(selectedRows[i]); selectedDataItems.push(dataItem); // selectedDataItems contains all selected data items } }, });
TreeView
TreeView web control
See: TreeView
Add TreeView Control
In html file add code:
<div id="treeview"></div>
In js file add code:
// key node id (must be unique inside the tree) // title display name (may contain HTML) // data ontains all extra data that was passed on node creation // children Array of child nodes. // expanded Use isExpanded(), setExpanded() to access this property. // folder folder nodes have different default icons and click behavior. // selected Use isSelected(), setSelected() to access this property. // tooltip Alternative description used as hover popup var dataSource = [ {key: "id1", title: "item1 with key and tooltip", tooltip: "Look, a tool tip!"}, {key: "id2", title: "item2"}, {key: "id3", title: "Folder <em>with some</em>", folder: true, expanded: true, children: [ { key: "id3.1", title: "Sub-item 3.1", folder: true, expanded: true, children: [ {key: "id3.1.1", title: "Sub-item 3.1.1"}, {key: "id3.1.2", title: "Sub-item 3.1.2"}, ], }, { key: "id3.2", title: "Sub-item 3.2", folder: true, children: [ {key: "id3.2.1", title: "Sub-item 3.2.1"}, {key: "id3.2.2", title: "Sub-item 3.2.2"}, ], }, {key: "id3.3", title: "Sub-item 3.3"}, ]}, ]; var treeview = new KQ.ui.TreeView('treeview', { source: dataSource});
Result:
Checkbox
In html file add code:
<div id="treeview"></div>
In js file add code:
var dataSource = [ {key: "id1", title: "item1 with key and tooltip", tooltip: "Look, a tool tip!"}, {key: "id2", title: "item2", selected: true}, {key: "id3", title: "Folder <em>with some</em>", folder: true, expanded: true, children: [ { key: "id3.1", title: "Sub-item 3.1", folder: true, expanded: true, children: [ {key: "id3.1.1", title: "Sub-item 3.1.1"}, {key: "id3.1.2", title: "Sub-item 3.1.2"}, ], }, { key: "id3.2", title: "Sub-item 3.2", folder: true, children: [ {key: "id3.2.1", title: "Sub-item 3.2.1"}, {key: "id3.2.2", title: "Sub-item 3.2.2"}, ], }, {key: "id3.3", title: "Sub-item 3.3"}, ]}, ]; var treeview = new KQ.ui.TreeView('treeview', { source: dataSource, checkbox: true});
Result:
Custom Icon
In html file add code:
<div id="treeview"></div>
In js file add code:
var dataSource = [ {key: "id1", title: "item1 with key and tooltip", tooltip: "Look, a tool tip!", icon: "line.png"}, {key: "id2", title: "item2", selected: true, icon: "point.png"}, {key: "id3", title: "Folder <em>with some</em>", folder: true, expanded: true, children: [ { key: "id3.1", title: "Sub-item 3.1", folder: true, expanded: true, children: [ {key: "id3.1.1", title: "Sub-item 3.1.1", icon: "line.png"}, {key: "id3.1.2", title: "Sub-item 3.1.2", icon: "polygon.png"}, ], }, { key: "id3.2", title: "Sub-item 3.2", folder: true, children: [ {key: "id3.2.1", title: "Sub-item 3.2.1"}, {key: "id3.2.2", title: "Sub-item 3.2.2"}, ], }, {key: "id3.3", title: "Sub-item 3.3", icon: "polygon.png"}, ]}, ]; var treeview = new KQ.ui.TreeView('treeview', { source: dataSource, imagePath: "../../images/"});
Result:
Select Event
In html file add code:
<div id="treeview"></div>
In js file add code:
var dataSource = [ {key: "id1", title: "item1 with key and tooltip", tooltip: "Look, a tool tip!", icon: "line.png"}, {key: "id2", title: "item2", selected: true, icon: "point.png"}, { key: "id3", title: "Folder <em>with some</em>", folder: true, expanded: true, children: [ { key: "id3.1", title: "Sub-item 3.1", folder: true, expanded: true, children: [ {key: "id3.1.1", title: "Sub-item 3.1.1", icon: "line.png"}, {key: "id3.1.2", title: "Sub-item 3.1.2", icon: "polygon.png"}, ], }, { key: "id3.2", title: "Sub-item 3.2", folder: true, children: [ {key: "id3.2.1", title: "Sub-item 3.2.1"}, {key: "id3.2.2", title: "Sub-item 3.2.2"}, ], }, {key: "id3.3", title: "Sub-item 3.3", icon: "polygon.png"}, ] }, ]; var treeview = new KQ.ui.TreeView('treeview', {source: dataSource, imagePath: "../../images/"}); treeview.on('click', function (paramers) { var data = paramers.data; var node = data.node; // key:id1, title:item1 with key and tooltip, tooltip:Look, a tool tip!, icon:line.png console.log("key:" + node.key + ", title:" + node.title + ", tooltip:" + node.tooltip + ", icon:" + node.icon); }, treeview);
Visit Function
In html file add code:
<div id="treeview"></div>
In js file add code:
var dataSource = [ {key: "id1", title: "item1 with key and tooltip", tooltip: "Look, a tool tip!", icon: "line.png"}, {key: "id2", title: "item2", selected: true, icon: "point.png"}, { key: "id3", title: "Folder <em>with some</em>", folder: true, expanded: true, children: [ { key: "id3.1", title: "Sub-item 3.1", folder: true, expanded: true, children: [ {key: "id3.1.1", title: "Sub-item 3.1.1", icon: "line.png"}, {key: "id3.1.2", title: "Sub-item 3.1.2", icon: "polygon.png"}, ], }, { key: "id3.2", title: "Sub-item 3.2", folder: true, children: [ {key: "id3.2.1", title: "Sub-item 3.2.1"}, {key: "id3.2.2", title: "Sub-item 3.2.2"}, ], }, {key: "id3.3", title: "Sub-item 3.3", icon: "polygon.png"}, ] }, ]; var treeview = new KQ.ui.TreeView('treeview', {source: dataSource, imagePath: "../../images/"}); var keys = []; treeview.visit(function (node) { keys.push(node.key); }); // id1, id2, id3, id3.1, id3.1.1, id3.1.2, id3.2, id3.2.1, id3.2.2, id3.3 console.log(keys.join(", "));
Lazy Load
In html file add code:
<div id="treeview"></div>
In js file add code:
// notice: lazy flag must true var source = [ {title: "item1", key: "item1", folder: true, lazy: true}, {title: "item2", key: "item2", folder: true, lazy: true}, {title: "item3", key: "item3", folder: true, lazy: true}, ]; var treeview = new KQ.ui.TreeView('treeview', {source: source}); // node: the current click node, return is a sub items array treeview.subItemsLazyLoadFn(function (node) { if (node.key === "item1"){ return [{title: "sub_item1_1"}, {title: "sub_item1_2"}]; }else if (node.key === "item2"){ return [{title: "sub_item2_1"}, {title: "sub_item2_2"}]; }else if (node.key === "item3"){ return [{title: "sub_item3_1"}, {title: "sub_item3_2"}, {title: "sub_item3_3"}]; } });
Result:
TreeViewNode's Usage
In html file add code:
<div id="treeview"></div>
In js file add code:
var dataSource = [ {key: "id1", title: "item1 with key and tooltip", tooltip: "Look, a tool tip!"}, {key: "id2", title: "item2"}, { key: "id3", title: "Folder <em>with some</em>", folder: true, expanded: true, children: [ { key: "id3.1", title: "Sub-item 3.1", folder: true, expanded: true, children: [ {key: "id3.1.1", title: "Sub-item 3.1.1"}, {key: "id3.1.2", title: "Sub-item 3.1.2"}, ], }, { key: "id3.2", title: "Sub-item 3.2", folder: true, children: [ {key: "id3.2.1", title: "Sub-item 3.2.1"}, {key: "id3.2.2", title: "Sub-item 3.2.2"}, ], }, {key: "id3.3", title: "Sub-item 3.3"}, ] }, ]; var treeview = new KQ.ui.TreeView("treeview", {source: dataSource, checkbox: true}); var treeViewNode = treeview.getNodeByKey('id3.1'); console.log(treeViewNode.isExpanded()); // true console.log(treeViewNode.isFolder()); // true console.log(treeViewNode.isSelected()); // false treeViewNode.setSelected(true); console.log(treeViewNode.isSelected()); // true
Window
Display a moveable, scalable window on the screen, it can be with a title, close button.
See: Window
Add Window
Display custom content in the new window.
- Find folder and open it: 'kqwebmap/window'.
Add new file 'example.html'.
<div id="example"> <div id="window"> <div class="armchair"> <img src="http://lorempixel.com/199/194" alt="Artek Alvar Aalto - Armchair 402"/> Artek Alvar Aalto - Armchair 402 </div> <p>Alvar Aalto is one of the greatest names in modern architecture and design. Glassblowers at the iittala factory still meticulously handcraft the legendary vases that are variations on one theme, fluid organic shapes that let the end user decide the use. Interpretations of the shape in new colors and materials add to the growing Alvar Aalto Collection that remains true to his original design.</p> <p>Born Hugo Alvar Henrik Aalto (February 3, 1898 - May 11, 1976) in Kuortane, Finland, was noted for his humanistic approach to modernism. He studied architecture at the Helsinki University of Technology from 1916 to 1921. In 1924 he married architect Aino Marsio.</p> <p>Alvar Aalto was one of the first and most influential architects of the Scandinavian modern movement, and a member of the Congres Internationaux d'Architecture Moderne. Major architectural works include the Finlandia Hall in Helsinki, Finland, and the campus of Helsinki University of Technology.</p> <p>Source: <a href="http://www.aalto.com/about-alvar-aalto.html" title="About Alvar Aalto">www.aalto.com</a></p> </div> <span id="undo" style="display:none" class="k-button hide-on-narrow">Click here to open the window.</span> <div class="responsive-message"></div> <button id="button" type="button" onclick="onExampleButtonClick()">Button</button> <script> function onExampleButtonClick () { console.log('onExampleButtonClick!'); } </script> <style> #undo { text-align: center; position: absolute; white-space: nowrap; padding: 1em; cursor: pointer; } .armchair { float: left; margin: 30px 30px 120px 30px; text-align: center; } .armchair img { display: block; margin-bottom: 10px; width: 199px; height: 194px; } @media screen and (max-width: 500px) { div.k-window { display: none !important; } } </style> </div>
Add code in js file.
KQ.Common.CommonTools.loadUiLib(function () { var win = new KQ.Control.Window('example', { parentID: 'map', position: { left: '100px', top: '100px', }, }); win.initAsync(); win.open(); });
Result: