Inline editing in jqGrid not working - asp.net-mvc

I am facing an issue in Inline editing, I have a jqGrid with pager. If the user changes the value of three cells suppose. After editing the third cell the user clicks on the next page button of the jqGrid pager. Now when the user returns back to the first page, only the changed values of the first two cells are retained and the third is lost. Please suggest how to retain the values of all the cells..?
Sample Code:
var mydata = [{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
},{
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
name: "New York City",
country: "USA",
continent: "North America"
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
name: "Paris",
country: "France",
continent: "Europe"
}]
$("#grid").jqGrid({
data: mydata,
datatype: "local",
colNames: ["Name", "Country", "Continent"],
colModel: [{
name: 'name',
index: 'name',
editable: true,
}, {
name: 'country',
index: 'country',
editable: true,
}, {
name: 'continent',
index: 'continent',
editable: true,
}],
rowNum: 10,
pager: '#pager',
'cellEdit': true,
'cellsubmit' : 'clientArray',
editurl: 'clientArray'
});

It's wrong to use cellEdit: true if you want to use inline editing. On the other side to use inline editing you have to start inline editing, for example you can start editRow inside of onSelectRow callback (see the documentation). So the code which you posted just ignores editurl: 'clientArray' and it works like pure cell editing.
The main problem which you have is unsaved data on paging. To solve the problem you need just call explicitly saveCell method inside of onPaging callback. The parameters iRow and iCol required for saveCell you can get as the property of the standard jqGrid options (using getGridParam method). The corresponding code can be line below:
onPaging: function () {
var $self = $(this), p = $self.jqGrid("getGridParam");
$self.jqGrid("saveCell", p.iRow, p.iCol);
}
The next potential problem in your code: the data are not full. The input data should contains id property to identify every item of input data. The array of input data contains for example multiple Toronto items. It could be just a problem in your test input. The data can be displayed in the grid in sorted form, so to it will be difficult to distinguish the items. It's strictly recommended to have id property assigned. You can get the modified data later using $("#grid").jqGrid("getGridParam", "data") and compare items with original data based on the id to see which one were changed.
I suggest that you add unique id property to every item. It could be for example 1,2,3 or 10,20,30 or something like that. The corresponding modified code is below. I added some options to jqGrid too. You can run the code and verify that the problem with unsaved data during paging is solved.
var mydata = [{
id: 10,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 20,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 30,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 40,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 50,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 60,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 70,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 80,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 90,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 100,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 110,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 120,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 130,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 140,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 150,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 160,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 170,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 180,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 190,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 200,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 210,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 220,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 230,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 240,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 250,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 260,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 270,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 280,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 290,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 300,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 310,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 320,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 330,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 340,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 350,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 360,
name: "Paris",
country: "France",
continent: "Europe"
},{
id: 370,
name: "Toronto",
country: "Canada",
continent: "North America"
}, {
id: 380,
name: "New York City",
country: "USA",
continent: "North America"
}, {
id: 390,
name: "Silicon Valley",
country: "USA",
continent: "North America"
}, {
id: 400,
name: "Paris",
country: "France",
continent: "Europe"
}];
$("#grid").jqGrid({
data: mydata,
datatype: "local",
colNames: ["Name", "Country", "Continent"],
colModel: [
{ name: 'name' },
{ name: 'country' },
{ name: 'continent' }
],
cmTemplate: { editable: true },
rowNum: 10,
pager: '#pager',
cellEdit: true,
cellsubmit: 'clientArray',
rownumbers: true,
gridview: true,
autoencode: true,
height: 'auto',
onPaging: function () {
var $self = $(this), p = $self.jqGrid("getGridParam");
$self.jqGrid("saveCell", p.iRow, p.iCol);
}
});
html, body { font-size: 75%; }
.ui-jqgrid-hdiv { overflow-y: hidden; }
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/redmond/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/css/ui.jqgrid.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/js/jquery.jqGrid.src.js"></script>
<table id="grid"><tr><td></td></tr></table>
<div id="pager"></div>

Related

Get all objects that has an array that contains a specific value

I have an array of objects called students that looks like this:
[
{
student_id: '1',
student_name: 'student 1',
courses: [
{ course_id: 'dxgk22452', course_name: 'courses 1' },
{ course_id: 'asdf9d2d', course_name: 'courses 2'},
{ course_id: 'h355dsf4', course_name: 'courses 3'}
]
},
{
student_id: '2',
student_name: 'student 2',
courses: [
{ course_id: 'asdf9d2d', course_name: 'courses 2'},
{ course_id: 'glld9432d2', course_name: 'courses 4' }
]
},
{
student_id: '3',
student_name: 'student 3',
courses: [
{ course_id: 'dxgk22452', course_name: 'courses 1' },
{ course_id: 'glld9432d2', course_name: 'courses 4' }
]
}
]
I am trying to figure out the best way to get all objects that contain a specific course id.
I tried students.where(courses.course_id == "dxgk22452") with no luck and could not find a post with my specific situation.
What would be the best way to go about this?
You can iterate twice to select those hashes, where their courses include at least one hash where its course_id is equal to dxgk22452:
data.select { |e| e[:courses].find { |f| f[:course_id] == 'dxgk22452' } }
Given an array:
students = [
{
student_id: '1',
student_name: 'student 1',
courses: [
{ course_id: 'dxgk22452', course_name: 'courses 1' },
{ course_id: 'asdf9d2d', course_name: 'courses 2'},
{ course_id: 'h355dsf4', course_name: 'courses 3'}
]
},
{
student_id: '2',
student_name: 'student 2',
courses: [
{ course_id: 'asdf9d2d', course_name: 'courses 2'},
{ course_id: 'glld9432d2', course_name: 'courses 4' }
]
},
{
student_id: '3',
student_name: 'student 3',
courses: [
{ course_id: 'dxgk22452', course_name: 'courses 1' },
{ course_id: 'glld9432d2', course_name: 'courses 4' }
]
}
]
Return the students whose courses include the given value:
students.select { |student| student[:courses].any? { |course| course[:course_id] == 'dxgk22452' } }
=> [
{
student_id: '1',
student_name: 'student 1',
courses: [
{ course_id: 'dxgk22452', course_name: 'courses 1' },
{ course_id: 'asdf9d2d', course_name: 'courses 2'},
{ course_id: 'h355dsf4', course_name: 'courses 3'}
]
},
{
student_id: '3',
student_name: 'student 3',
courses: [
{ course_id: 'dxgk22452', course_name: 'courses 1' },
{ course_id: 'glld9432d2', course_name: 'courses 4' }
]
}
]

Tabulator and Select2, not showing selecte value at load

I want to use Select2 in Tabulator but triggering the selected value does not work.
Here is my code of the formatter for the table column:
{
title: "Select2", field: "lucky_no", align: "center", width: 300, editor: true,
formatter: function (cell, formatterParams, onRendered) {
onRendered(function () {
var select_2 = $(cell.getElement());
select_2.select2({
theme: "classic",
placeholder: 'Select',
data: list,
minimumResultsForSearch: Infinity,
width: 300,
minimumInputLength: 0,
allowClear: true,
}).on('change', function (e) {
console.log('change');
});
select_2.val(list[cell.getValue()].id);
var x = select_2.val();
select_2.val(x).trigger('change');
})
}
},
I have added a working example.
Triggering the selected value works in drop-down above the table.
Although in the table the change event is triggered it does not show the selected value in the dropdown.
Thanks,
Aad
If you are trying to make the field editable, you should be creating a custom editor not a formatter
Formatters are for displaying data to users, editors are for allowing the user to edit the data.
Built In Select Editor
Before I go to far into this example, did you know that Tabulator already comes with a Select Editor built-in to make your life even easier, in the demo in the documentation, have a look at the gender column to see it in action.
Custom Editor
When using custom editors, they come with select and cancel call backs to allow you to pass the data back into the table.
So for your example it should look something like this (this code is untested)
//create custom editor
var select2Editor = function(cell, onRendered, success, cancel, editorParams){
//create input element to hold select
var editor = document.createElement("input");
onRendered(function(){
var select_2 = $(editor);
select_2.select2({
theme: "classic",
placeholder: 'Select',
data: list,
minimumResultsForSearch: Infinity,
width: 300,
minimumInputLength: 0,
allowClear: true,
});
select_2.on('change', function (e) {
success(select_2.val());
});
select_2.on('blur', function (e) {
cancel();
});
});
//add editor to cell
return editor;
}
//in your column definition for the column
{title: "Select2", field: "lucky_no", align: "center", width: 300, editor: select2Editor},
My first question .. this was not included!
var tabledata = [{
id: 1,
name: "Oli Bob",
progress: 12,
location: "United Kingdom",
gender: "male",
rating: 1,
col: "red",
dob: "14/04/1984",
car: 1,
lucky_no: 3
},
{
id: 2,
name: "Mary May",
progress: 1,
location: "Germany",
gender: "female",
rating: 2,
col: "blue",
dob: "14/05/1982",
car: true,
lucky_no: 2
},
{
id: 3,
name: "Christine Lobowski",
progress: 42,
location: "France",
gender: "female",
rating: 0,
col: "green",
dob: "22/05/1982",
car: "true",
lucky_no: 5
},
{
id: 4,
name: "Brendon Philips",
progress: 100,
location: "USA",
gender: "male",
rating: 1,
col: "orange",
dob: "01/08/1980",
lucky_no: 7
},
{
id: 5,
name: "Margret Marmajuke",
progress: 16,
location: "Canada",
gender: "female",
rating: 5,
col: "yellow",
dob: "31/01/1999",
lucky_no: 4
},
];
var list = [{
"id": 1,
"text": "Organisatorische tekortkomingen"
}, {
"id": 2,
"text": "Mechanische gevaren"
}, {
"id": 3,
"text": "Hijs-/hefgevaren"
}, {
"id": 4,
"text": "Ergonomische tekortkomingen"
}, {
"id": 5,
"text": "Mobiliteit en gevaarlijke situaties"
}, {
"id": 6,
"text": "Elektrische gevaren"
}, {
"id": 7,
"text": "Blootstelling aan gevaarlijke stoffen"
}, {
"id": 8,
"text": "Gevaarlijke situaties - Algemeen"
}, {
"id": 9,
"text": "Blootstelling aan straling"
}, {
"id": 10,
"text": "Druk"
}, {
"id": 11,
"text": "Blootstelling aan trillingen"
}, {
"id": 12,
"text": "Blootstelling aan geluid"
}, {
"id": 13,
"text": "Fysieke gevaren (overig)"
}, {
"id": 14,
"text": "Gevaar voor/door derden (hijsen/heffen)"
}, {
"id": 15,
"text": "Hijsen/heffen en ergonomische tekortkomingen"
}, {
"id": 16,
"text": "Mobiliteit en werkplek/bestuurdersplaats"
}, {
"id": 17,
"text": "Mobiliteit en ergonomische tekortkomingen"
}, {
"id": 18,
"text": "Mobiliteit en energiebron en -overbrenging"
}, {
"id": 19,
"text": "Mobiliteit en stabiliteit"
}, {
"id": 20,
"text": "Gevaarlijke situaties door onverwachte opstart/beweging"
}, {
"id": 21,
"text": "Gevaren beheerst!",
"scope": "Algemeen"
}, {
"id": 22,
"text": "NIET beoordeeld!"
}];
$('#selectList').select2({
data: list,
minimumResultsForSearch: Infinity,
width: 'resolve',
minimumInputLength: 0,
allowClear: true,
placeholder: "Select",
});
$('#selectList').val(7).trigger('change');
//Build Tabulator
var table = new Tabulator("#example-table", {
height: "500px",
columns: [{
title: "Name",
field: "name",
width: 150
},
{
title: "Location",
field: "location",
width: 130
},
{
title: "Progress",
field: "progress",
sorter: "number",
align: "left",
formatter: "progress",
width: 140
},
{
title: "Gender",
field: "gender",
editor: "select",
editorParams: {
"male": "Male",
"female": "Female"
}
},
{
title: "Rating",
field: "rating",
formatter: "star",
align: "center",
width: 100
},
{
title: "Date Of Birth",
field: "dob",
align: "center",
sorter: "date"
},
{
title: "Driver",
field: "car",
align: "center",
formatter: "tickCross"
},
{
title: "Select2",
field: "lucky_no",
align: "center",
width: 300,
//editor: true,
formatter: function(cell, formatterParams, onRendered) {
onRendered(function() {
var select_2 = $(cell.getElement());
select_2.select2({
theme: "classic",
placeholder: 'Select',
data: list,
minimumResultsForSearch: Infinity,
width: 300,
minimumInputLength: 0,
allowClear: true,
}).on('change', function(e) {
//console.log('change');
});
select_2.val(list[cell.getValue()].id);
var x = select_2.val();
select_2.val(x).trigger('change');
})
}
},
],
});
//load sample data into the table
table.setData(tabledata);
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://unpkg.com/tabulator-tables#4.1.3/dist/css/tabulator.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/tabulator-tables#4.1.3/dist/js/tabulator.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
<html>
<body>
<div>
<select class="form-control" name="selectList" id="selectList">
</select>
</div>
<br />
<div id="example-table" class="table-striped table-bordered"></div>
</body>
</html>

Coloring Country while showing mappoint for cities in world map using highmaps

I am working with highmaps and have plotted the cities with map-points using lat-long for the same.
Now , I want to color particular countries say India and USA .
Is there any way to achieve the same ?
Below is my js file for plotting world map with citis mappoints with help of lat/lon
// Initiate the chart
$.getJSON("/MyProject/HighChartPhp/getMapData.php", function (data) {
// Correct UK to GB in data
$.each(data, function () {
if (this.code === 'UK') {
this.code = 'GB';
}
});
//console.log(data);
var final_array = [];
for(var i in data[0].data)
{
var map_data = {
name: data[0].name[i],
lat: data[0].lat[i],
lon: data[0].lon[i],
z: data[0].data[i],
val: data[0].loc[i],
color: data[0].color[i]
}
//console.log(map_data);
final_array[i] = map_data;
}
console.log(final_array);
Highcharts.mapChart('container', {
chart: {
borderWidth: 1,
map: 'custom/world'
},
title: {
text: 'Word Wide Data Usage'
},
subtitle: {
text: ''
},
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.val}</b><br/>{point.z}'
},
legend: {
enabled: false
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
series: [{
// Use the gb-all map with no data as a basemap
mapData: Highcharts.maps['custom/world'],
name: 'Basemap',
borderColor: 'green',
nullColor: 'rgba(200, 200, 200, 0.3)',
showInLegend: true
}, {
// Specify points using lat/lon
type: 'mappoint',
name: 'Cities',
//color: 'blue',
data: final_array
}]
});
});
How can I color India and US in the map ?
Tried the below , but still it is not working .
// Initiate the chart
$.getJSON("/MyProject/HighChartPhp/getMapData.php", function (data) {
// Correct UK to GB in data
$.each(data, function () {
if (this.code === 'UK') {
this.code = 'GB';
}
});
data.forEach(function(point, index) {
console.log("country="+point.country);
if (point.country === 'India' || point.country === 'United States') {
point.color = 'green';
}
});
//console.log(data);
var final_array = [];
for(var i in data[0].data)
{
var map_data = {
name: data[0].name[i],
lat: data[0].lat[i],
lon: data[0].lon[i],
z: data[0].data[i],
val: data[0].loc[i],
color: data[0].color[i],
country:data[0].country[i]
}
//console.log(map_data);
final_array[i] = map_data;
}
console.log(final_array);
Highcharts.mapChart('container', {
chart: {
borderWidth: 1,
map: 'custom/world'
},
title: {
text: 'Word Wide outsource Vendor Usage'
},
subtitle: {
text: ''
},
colorAxis: {
min: 1,
max: 1000,
type: 'logarithmic'
},
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.val}</b><br/>{point.z}'
},
legend: {
enabled: false
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
series: [{
// Use the gb-all map with no data as a basemap
mapData: Highcharts.maps['custom/world'],
joinBy: ['iso-a2', 'code'],
name: 'Basemap',
borderColor: 'green',
nullColor: 'rgba(200, 200, 200, 0.3)',
showInLegend: true
}, {
// Specify points using lat/lon
type: 'mappoint',
name: 'Cities',
//color: 'blue',
data: final_array
}]
});
});
Below is json data :
"name": [
"Ahemdabad",
"Atlanta",
"Bangalore",
"Bangkok",
"Buenos Aires",
"Chennai",
"Chicago",
"Cochin",
"Colombo",
"Dallas",
"Delhi",
"Hyderabad",
"Irvine",
"Irvine Dallas",
"Johannesburg",
"Kolkata",
"Kuala Lumpur",
"Lima",
"Los Angeles",
"Miami",
"Moscow",
"Mumbai",
"New Jersey",
"New York",
"Niagra",
"Philadelphia",
"Rio",
"Riyadh",
"Seattle",
"Syracuse",
"Washington Baltimore"
],
"loc": [
"Ahemdabad:India",
"Atlanta:USA",
"Bangalore:India",
"Bangkok:Thailand",
"Buenos Aires:Argentina",
"Chennai:India",
"Chicago:USA",
"Cochin:India",
"Colombo:Sri Lanka",
"Dallas:USA",
"Delhi:India",
"Hyderabad:India",
"Irvine:USA",
"Irvine Dallas:USA",
"Johannesburg:South Africa",
"Kolkata:India",
"Kuala Lumpur:Malaysia",
"Lima:Peru",
"Los Angeles:USA",
"Miami:USA",
"Moscow:Russia",
"Mumbai:India",
"New Jersey:USA",
"New York:USA",
"Niagra:USA",
"Philadelphia:USA",
"Rio:Brazil",
"Riyadh:Saudi Arabia",
"Seattle:USA",
"Syracuse:USA",
"Washington Baltimore:USA"
],
"color": [
"#FFC300",
"#EC32BF",
"#FFC300",
"#EC32BF",
"#49EC32",
"#FFC300",
"#EC3246",
"#FFC300",
"#EC32BF",
"#EC3246",
"#EC32BF",
"#FFC300",
"#EC32BF",
"#16F7EC ",
"#EC32BF",
"#FFC300",
"#EC32BF",
"#FFC300",
"#581845",
"#EC32BF",
"#EC32BF",
"#FFC300",
"#EC32BF",
"#EC32BF",
"#3A32EC",
"#EC32BF",
"#49EC32",
"#EC32BF",
"#EC32BF",
"#EC32BF",
"#EC32BF"
],
"lat": [
23.022505,
33.748995,
12.971599,
13.756331,
-34.603684,
13.08268,
41.878114,
9.931233,
6.927079,
32.776664,
28.704059,
17.385044,
33.684567,
33.684567,
-26.204103,
22.572646,
3.139003,
-12.046373,
34.052234,
25.76168,
55.755826,
19.075984,
40.058324,
40.712784,
43.082816,
39.952584,
-22.906847,
24.713552,
47.606209,
43.048122,
39.177404
],
"lon": [
72.571362,
-84.387982,
77.594563,
100.501765,
-58.381559,
80.270718,
-87.629798,
76.267304,
79.861243,
-96.796988,
77.10249,
78.486671,
-117.826505,
-117.826505,
28.047305,
88.363895,
101.686855,
-77.042754,
-118.243685,
-80.19179,
37.6173,
72.877656,
-74.405661,
-74.005941,
-79.074163,
-75.165222,
-43.172896,
46.675296,
-122.332071,
-76.147424,
-76.668392
],
"country": [
"India",
"USA",
"India",
"Thailand",
"Argentina",
"India",
"USA",
"India",
"Sri Lanka",
"USA",
"India",
"India",
"USA",
"USA",
"South Africa",
"India",
"Malaysia",
"Peru",
"USA",
"USA",
"Russia",
"India",
"USA",
"USA",
"USA",
"USA",
"Brazil",
"Saudi Arabia",
"USA",
"USA",
"USA"
]
}
You can add property to specific points from the data, before joining with mapData.
API Reference:
http://api.highcharts.com/highmaps/series%3Cmappoint%3E.data.color
Example:
http://jsfiddle.net/0Lcwn3pj/

How to model schema for list of embedded dictionaires in python eve

I have a Document where a user has 2 addresses such as below. How would I create a schema for this in python-eve?
Also, How would I create an API request to allow a user to update only the zipcode. Do they have to repost the entire document?
{
_id: "joe",
name: "Joe Bookreader",
addresses: [
{
street: "123 Fake Street",
city: "Faketon",
state: "MA",
zip: "12345"
},
{
street: "1 Some Other Street",
city: "Boston",
state: "MA",
zip: "12345"
}
]
}
As far as the schema goes, this should do the trick (docs):
'addresses': {
'type': 'list',
'schema' {
'type': 'dict',
'schema': {
'street': {'type': 'string'},
'city': {'type': 'string'},
'state': {'type': 'string'},
'zip': {'type': 'string'}
}
}
}
Dot notation is supported for PATCH (update) requests, but not on lists of documents. They are trickier, and hard to do in a RESTful way. There's an open ticket for that right now, but not direct solution yet, I am afraid.

how to implement custom grouping in jqGrid

I'm starter in jqGrid, i write this code for Implement Grouping
$(function () {
var mydata = [
{ id: "11", invdate: "2007-10-01", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "12", invdate: "2007-10-02", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "13", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
{ id: "14", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "15", invdate: "2007-10-05", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "16", invdate: "2007-09-06", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
{ id: "17", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "18", invdate: "2007-10-03", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "19", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
{ id: "21", invdate: "2007-10-01", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "22", invdate: "2007-10-02", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "23", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
{ id: "24", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "25", invdate: "2007-10-05", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "26", invdate: "2007-09-06", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
{ id: "27", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "28", invdate: "2007-10-03", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "29", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00"}];
jQuery("#list48").jqGrid({
data: mydata,
datatype: "local",
height: 'auto',
rowNum: 30,
rowList: [10, 20, 30],
colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
colModel: [
{ name: 'id', index: 'id', width: 60, sorttype: "int" },
{ name: 'invdate', index: 'invdate', width: 90, sorttype: "date", formatter: "date" },
{ name: 'name', index: 'name', width: 100, editable: true },
{ name: 'amount', index: 'amount', width: 80, align: "right", sorttype: "float", formatter: "number", editable: true },
{ name: 'tax', index: 'tax', width: 80, align: "right", sorttype: "float", editable: true },
{ name: 'total', index: 'total', width: 80, align: "right", sorttype: "float" },
{ name: 'note', index: 'note', width: 150, sortable: false}],
pager: "#plist48",
viewrecords: true,
sortname: 'name',
grouping: true,
groupingView: { groupField: ['name'] },
caption: "Grouping Array Data" });
});
and create this grid
i want set Grouping Dynamicaly.Such that user Drag Header Column and Drop in top box after that grid Grop such this picture
please help me for implement this senaryo
. thanks all
On the jqGrid side you need to use groupingRemove and groupingGroupBy methods to change grouping dynamic, you can read more about them in documentation.
For the UI part you should look at following interactions:
Draggable
Droppable
Sortable
The Shopping Cart sample in Droppable should give you a very good overview on how to approach the subject.
Now after all that theoretical informations, I have created a sample on jsFiddle for you: jqGrid dynamic drag-n-drop grouping. It needs some styling to look exactly as what you are looking for, but it should allow you to understand all the internals. If you need some comments on the code let me know - I can add them later.

Resources