Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: f4dedbafa8
Fetching contributors…

Cannot retrieve contributors at this time

136 lines (124 sloc) 4.753 kB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SQL Editor</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/redmond/jquery-ui.css" type="text/css" rel="Stylesheet" />
<link rel="stylesheet" type="text/css" media="screen" href="themes/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="themes/ui.multiselect.css" />
<link rel="stylesheet" type="text/css" media="screen" href="themes/grid_styles.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js" type="text/javascript" charset="ISO-8859-1"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js" type="text/javascript" charset="ISO-8859-1"></script>
<script src="js/knockout-1.2.1.js" type="text/javascript"></script>
<script src="js/knockout.mapping.js" type="text/javascript"></script>
<script src="js/jquery.layout.js" type="text/javascript"></script>
<script src="js/grid.locale-en.js" type="text/javascript"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script src="js/ui.multiselect.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="js/grid.common.js" type="text/javascript"></script>
<script src="js/grid.formedit.js" type="text/javascript"></script>
<script src="js/jquery.tablednd.js" type="text/javascript"></script>
<script src="js/jquery.contextmenu.js" type="text/javascript"></script>
<script src="js/main_grid.js" type="text/javascript"></script>
<script type='text/javascript'>//<![CDATA[
$(function(){
dataArr = [
({
"ID": 1,
"(": "(",
"Column": "FirstName",
"Operator": "Equal To",
"Value": "richard",
")": ")",
"Seperator": "OR",
"Statement": "",
}),
({
"ID": 2,
"(": "(",
"Column": "Active",
"Operator": "Equal To",
"Value": "1",
")": ")",
"Seperator": "",
"Statement": "",
})
]
window.Grid = new (function(){
var self = this;
this.conditions = ko.observableArray(dataArr)
this.selectCondition = function(){
console.log('select me')
}
this.selectedCondition = new (function(){
var self = this;
this.selectedName = ko.observable("one")
this.selectedOperator = ko.observable("")
this.list = [
{name: 'one', subList: ['1-1:1-1', '1-2:1-2']},
{name: 'two', subList: ['2-1:2-1', '2-2:2-2']},
{name: 'three', subList: ['3-1:3-1', '3-2:3-2']}
]
this.getGridColumns = this.list.map(function(o){ return o.name + ":" + o.name }).join(";");
this.getOperators = ko.computed(function(){
var x = ko.utils.arrayFirst(this.list, function(o){
if (self.selectedName() && self.selectedName() == o.name )
return true
})
if (x)
return x.subList; //.join(";")
}, self)
this.operatorTemplate = function(value, options){
setTimeout(function(){
ko.applyBindings(Grid, $("#" + options.id).get(0))
},250)
return '<select data-bind="value: selectedCondition.selectedOperator, options: selectedCondition.getOperators"></select>';
}
this.getElemValue = function(e){
return $(e).val();
}
})()
})()
ko.applyBindings(Grid)
});//]]>
</script>
</head>
<body>
<div id="container">
<table id="conditionsGrid" data-bind="grid: {
data: Grid.conditions,
selectItem: Grid.selectCondition,
caption: 'Criteria Builder',
pager: '#gridpager',
colModel: [
{
name: 'Column', index: 'Column', width: 200, editable: true, edittype: 'select',
editoptions: {
value: selectedCondition.getGridColumns,
dataEvents: [
{ type: 'click', fn: function(e) { selectedCondition.selectedName(e.target.value); } }
]
}
},
{
name: 'Operator', index: 'Operator', width: 150, editable: true, edittype: 'custom',
editoptions: {
custom_element: selectedCondition.operatorTemplate,
custom_value: selectedCondition.getElemValue,
dataEvents: [
{ type: 'click', fn: function(e) { selectedCondition.selectedOperator(e.target.value); } }
]
}
}
],
rowId: 'ID'
}">
</table>
<div id="navPager"></div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.