I want to incorporate delete button in the actions column. It can come beside can cel button. This is how it looks as of now-
This is my code:
<script>
var task_link = "http://localhost/cssdeck/dashboard/dashboar.php?Emp_ID=";
$(document).ready(function () {
$("#emp_grid").jqGrid({
url: "getGridData.php?q=3",
datatype: "json",
colNames: ["Emp Id", "Emp Name", "Emp Start Date", "Emp End Date" , "Percent", "Status","ACTIONS"],
colModel: [
{ name: "emp_id",index:"emp_id",editable:true,formatter: formatEmpID},
{ name: "emp_name",index:"emp_name",align:"center",editable:true},
{ name: "emp_startDate",index:"emp_startDate",sorttype:'date',edittype:"text",formatter: 'date',formatoptions: { srcformat: 'Y/m/d', newformat: 'm/d/Y'},editable:true,
editoptions: {
// dataInit is the client-side event that fires upon initializing the toolbar search field for a column
// use it to place a third party control to customize the toolbar
dataInit: function (element) {
$(element).datepicker({
dateFormat: 'mm/dd/yy',
//minDate: new Date(2010, 0, 1),
maxDate: new Date(2020, 0, 1),
showOn: 'focus'
});
}
},
searchoptions: {
dataInit: function(elem) {
$(elem).datepicker({
dateFormat: 'mm/dd/yy',
//minDate: new Date(2010, 0, 1),
maxDate: new Date(2020, 0, 1),
showOn: 'focus'
});
}
}
},
{ name: "emp_endDate",index:"emp_endDate",sorttype:'date',edittype:"text",formatter: 'date',formatoptions: { srcformat: 'Y/m/d', newformat: 'm/d/Y'},editable:true,
editoptions: {
// dataInit is the client-side event that fires upon initializing the toolbar search field for a column
// use it to place a third party control to customize the toolbar
dataInit: function (element) {
$(element).datepicker({
dateFormat: 'mm/dd/yy',
//minDate: new Date(2010, 0, 1),
maxDate: new Date(2020, 0, 1),
showOn: 'focus'
});
}
},
searchoptions: {
dataInit: function(elem) {
$(elem).datepicker({
dateFormat: 'mm/dd/yy',
//minDate: new Date(2010, 0, 1),
maxDate: new Date(2020, 0, 1),
showOn: 'focus'
});
}
}
},
{ name: "percentComplete",index:"percentComplete",editable:true},
{ name: "emp_status",index:"emp_status",editable:true,edittype:"select",editoptions: {value:"Onboarding:Onboarding;Released:Released"}},
{name:'act',index:'act', width:130,sortable:false}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pemp_grid',
loadonce:true,
ignoreCase: true,
viewrecords: true,
autowidth:true,
cmTemplate: { title: false },
height:'100%',
gridComplete: function(){
var ids = jQuery("#emp_grid").jqGrid('getDataIDs');
for(var i=0;i<ids.length;i++){
var cl = ids[i];
be = "<input style='height:22px;width:40px;' type='button' value='Edit' onclick=\"jQuery('#emp_grid').jqGrid('editRow','"+cl+"');\" />";
se = "<input style='height:22px;width:40px;' type='button' value='Save' onclick=\"jQuery('#emp_grid').jqGrid('saveRow','"+cl+"');\" />";
ce = "<input style='height:22px;width:50px;' type='button' value='Cancel' onclick=\"jQuery('#emp_grid').jqGrid('restoreRow','"+cl+"');\" />";
jQuery("#emp_grid").jqGrid('setRowData',ids[i],{act:be+se+ce});
}
},
editurl: "update.php",
caption: "Employee Details"
});
$("#emp_grid").jqGrid('navGrid',"#pemp_grid",{edit:false,del:false,refresh: false, search: false} );
$("#emp_grid").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn" });
});
function formatEmpID(cellvalue, options, rowObject) {
var link = task_link + cellvalue;
return "<a href='" + link + "' target='_blank'>" + cellvalue + "</a>";
}
</script>
I have been trying to achieve this from past 2 days but all effort in vain.
Would really appreciate any help.
Related
I use DataTables to format my tables on a reporting website that I run. I am using the initialization to add a hyperlink to the first column of my tables. Is there a way to make it act like a button instead of a hyperlink?
I need this because I have the hyperlink sending the whole row as part of the link (so through GET), but it's failing because of the limit on characters in GET. I need to use a POST so that I can send this larger amount of data.
The definition of the hyperlink is:
data = '' + data + '';
Here's the full datatables initialization to show the hyperlink in context:
$.fn.dataTable.ext.buttons.export =
{
className: 'buttons-alert',
"text": "Export All Test",
action: function (e, dt, node, config)
{
alert('Export All Test');
}
};
$(document).ready(function ()
{
// Setup - add a text input to each footer cell
$('#DataTableEdit tfoot th').each(function ()
{
var title = $(this).text();
$(this).html('<input type="text" placeholder="Search ' + title + '" />');
});
var table = $('#DataTableEdit').DataTable({
"lengthMenu": [[25, 50, 75, 100, 150, -1], [25, 50, 75, 100, 150, 'All']],
"dom": '<"top"Bifpl<"clear">>rt<"bottom"ip<"clear">>',
"buttons": [{
extend: 'collection',
text: 'Selection',
buttons: ['selectAll', 'selectNone']
}, {
extend: 'collection',
text: 'Export',
buttons: ['export', 'excel', 'csv', 'pdf', { extend: 'excel',
text: 'Export Current Page',
exportOptions: {
modifier: {
page: 'current'
}
},
customize: function (xlsx)
{
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row:first c', sheet).attr('s', '7');
}
},
{
text: 'Export All to Excel',
action: function (e, dt, button, config)
{
dt.one('preXhr', function (e, s, data)
{
data.length = -1;
}).one('draw', function (e, settings, json, xhr)
{
var excelButtonConfig = $.fn.DataTable.ext.buttons.excelHtml5;
var addOptions = { exportOptions: { 'columns': ':all'} };
$.extend(true, excelButtonConfig, addOptions);
excelButtonConfig.action(e, dt, button, excelButtonConfig);
}).draw();
}
}]
}
],
"fixedHeader": {
header: true,
footer: true
},
"select": true,
"processing": true,
"serverSide": true,
"ajax": {
"url": "./ServerSide.php",
"type": "POST"
},
//This is the part that adds the hyperlink
columnDefs: [
{
targets: 0,
render: function (data, type, row, meta)
{
if (type === 'display')
{
data = '' + data + '';
}
return data;
}
}],
//End of hyperlink creation
initComplete: function ()
{
var api = this.api();
// Apply the search
api.columns().every(function ()
{
var that = this;
$('input', this.footer()).on('keyup change', function ()
{
if (that.search() !== this.value)
{
that
.search(this.value)
.draw();
}
});
});
}
});
});
If I don't have enough information let me know and I'll add more.
You can try and enclose it inside a <form> tag which will make it submit as post
if (type == 'display'){
data = '<form action="FormToEdit.php" method="post"><button type="submit"
class="btn-as-link" value = \'' +
encodeURIComponent(row) + '\'>' + data + '</button></form>' ;
}
And you can make it look like a link:
.btn-as-link{
border: none;
outline: none;
background: none;
cursor: pointer;
padding: 0;
text-decoration: underline;
}
Hi I have one issue i was creating one HighChart in this Static values to the series data section is working finely. but The same type value from a dynamic section is not showing.
function getusercategorygraph()
{
$.getJSON('config/alumniusermodes.php',function(data){
//alert(json);
//alert($.parseJSON(data));
//alert(obj);
var finaldata = '[';
var tmp = '';
var chart;
$.each(data, function( index, value ) {
finaldata += '{';
$.each(value, function( index, value ) {
//alert(index);
if(index === 'name')
{
tmp = " " + index + " : '" + value + "', ";
}
else
{
tmp = " " + index + " : " + value + ", ";
}
finaldata += tmp;
//alert("finaldata: " + finaldata);
});
finaldata+='},';
});
finaldata +=']';
//alert(finaldata);
chart = new Highcharts.Chart({
chart: {
/* backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
stops: [
[0, 'rgb(0, 0, 0)'],
[1, 'rgb(0, 0, 0)']
]
},*/
renderTo : 'user-count',
type: 'column',
},
title: {
text: 'Alumni Users By Category Analytics'
},
xAxis: {
color:'#0077CC',
type: 'category'
},
yAxis: {
title: {
text: 'Total Number of Alumni Members'
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y} Members'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y} Members</b><br/>'
},
series: [{
name: "Alumni Type",
colorByPoint: true,
//sdata: [{ name : 'Standard', y : 52, },{ name : 'Silver', y : 24, },{ name : 'Gold', y : 20, },{ name : 'Platinum', y : 6, },]
data: [{ name : 'Standard', y : 52, },{ name : 'Silver', y : 24, },{ name : 'Gold', y : 20, },{ name : 'Platinum', y : 6, },]
//data : finaldata,
}],
});
///chart.series[2].data.push(finaldata);
});
}
i am getting final data like this only
[{ name : 'Standard', y : 52, },{ name : 'Silver', y : 24, },{ name : 'Gold', y : 20, },{ name : 'Platinum', y : 6, },]
but i cant load that in this graph but when paste same value in static mode its showing correctly.
now its showinng a blank section only.
I am new to HighCharts Please help. Thanks in advance.
Your code is creating finaldata as a string, when you want to produce an array. You should have better luck with something like this:
// Create a new array
var finaldata = []
var chart;
// Perform your operations
$.each(data, function( index, value ) {
// Create a new hash
var currentItem = {}
// Create the proper values in your hash
$.each(value, function( index, value ) {
currentItem[index] = value;
});
// Push the new hash to the array
finaldata += currentItem;
});
If all of your data is being passed in a way that your old code successfully created the string you shared, then this should build the object for which you are looking.
To test this you may first want to try leaving your code exactly how it is, and parsing the string to JSON:
// Use this instead of 'data : finaldata'
data: JSON.parse( finaldata ),
This will try to turn your string into the objects on which you are trying to operate. That said, it would be in poor form to practice building an array via string manipulation. I would very strongly encourage you to follow the first approach I detailed.
Hi i Found this as For My Query.
var finaldata = [];
$.getJSON('config/alumniusermodes.php',function(data){
// Create a new array
var finaldata = [];
var chart;
var categories = [];
var tools = [];
$.each(data, function( index, value ) {
var currentItem = {}
finaldata.push({
name: value.name,
y: parseFloat(value.y)
});
});
var chart = new Highcharts.Chart({
chart: {
renderTo : 'user-count',
type: 'column',
},
title: {
text: 'Alumni Users By Category Analytics'
},
xAxis: {
color:'#0077CC',
categories: categories
},
yAxis: {
title: {
text: 'Total Number of Alumni Members'
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y} Members'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y} Members</b><br/>'
},
series: [{
name: "Alumni Type",
colorByPoint: true,
data : finaldata,
}],
});
});
This is my right coding which solved my issue
I have working php script that stores the name and address of the company in variables. I then echo it out like this:
$(document).ready(function() {
$("#map").gmap3({
marker:{
address: "<?echo $coord;?>"
},
map:{
options:{
zoom:15,
mapTypeControl: true,
navigationControl: true,
scrollwheel: true,
streetViewControl: true
}
}
});
});
How would I add the name of the company to show below the marker? For example: this?
I tried to add:
marker:{
address: "<?echo $coord;?>"
title: "<?echo $com_name;?>"
}
But this doesn't work.
Thank you.
The title property must be inside option property.
var marker = {
latLng: [53.23564, 24.32654],
data: 'some data',
options: {
title: 'Title',
icon: '/Path/to/custom/icon/if/you/need.png'
}
}
Other information you can show with infowindow.
Example:
$(".gmap-widget .gmap3").gmap3({
action: "addMarkers",
markers: markers,
marker: {
events: {
click: function(marker, event, data){
var map = $(this).gmap3('get');
infowindow = $(this).gmap3({action:'get', name:'infowindow'});
if (infowindow){
infowindow.open(map, marker);
infowindow.setContent(data);
} else {
$(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data, maxWidth: 300}});
}
}
}
}
});
I had a jqGrid and I had put a datepicker on the search column. When I click the datepicker, it come out and allow me to choose any date I want. However, after date selection it wont help me to filter my result. But if I type the same date on the column jqGrid will do the filtering for me.
Here is my code.
{name:columnArr4[3], index:columnArr4[3], width:106, sortable: true, fixed:true, resizable:false, // expiry date
formatter: function (cellvalue, options, rowObject)
{
celVal = '-';
if (cellvalue && cellvalue.replace(/\s/g, '').length>0){
celVal = cellvalue;
}
return celVal;
},
search:true, stype:'text', searchoptions: { dataInit: function(el) {
$(el).datepicker({
dateFormat: 'yy-mm-dd'
});
}
}
},
dataInit: function (elem) {
$(elem).datepicker({
changeYear: true,
changeMonth: true,
showButtonPanel: true,
onSelect: function() {
if (this.id.substr(0, 3) === "gs_") {
// in case of searching toolbar
setTimeout(function(){
myGrid[0].triggerToolbar();
}, 50);
} else {
// refresh the filter in case of
// searching dialog
$(this).trigger('change');
}
}
});
}
I get values to MySql database everyday at each hour.
I got site with highcharts, but I cant get it to work.
I need to get current day values from MySql organized to own hours.
Here is my Highcharts code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript">
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'chart',
defaultSeriesType: 'spline'
},
title: {
text: "Today's Values"
},
subtitle: {
text: 'Values by Hour'
},
credits: {
enabled: false
},
xAxis: {
categories: ['12AM', '1AM', '2AM', '3AM', '4AM', '5AM',
'6AM', '7AM', '8AM', '9AM', '10AM', '11AM','12PM', '1PM', '2PM', '3PM', '4PM', '5PM',
'6PM', '7PM', '8PM', '9PM', '10PM', '11PM']
},
yAxis: {
min: 0,
title: {
text: 'Values'
},
labels: {
formatter: function() {
return this.value
}
}
},
tooltip: {
valueDecimals: 2,
crosshairs: true,
shared: true,
formatter: function() {
return '$' + this.y;
}
},
plotOptions: {
spline: {
marker: {
radius: 4,
lineColor: '#666666',
lineWidth: 1
}
}
},
series: [{
name: 'Values',
data: [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
}]
});
});
</script>
Here is pic from MySql database how it looks like
chart
So, I need all values from MySql categorized to own hours at chart.
It should count values + show it at own category, any idea how to do this?
Im stuck with this beacause I dont know how to do this.
I advice to familiar with article about preprocessing data form MySQL http://docs.highcharts.com/#preprocessing-data-from-a-database
You should export your data from php as JSON, then if you would like you use categories for xAxis, you need to parse your JSON and push appropaite data to correct place.Similar with data points in series.