How to display total of records in jqgrid - jqgrid

I am trying to display total records in jqgrid.
Here is the code i am using to display.grid is displaying but i am not getting total.
and i am getting Error:footer-row is invalid propert
Can anyone tell me what is mistake?
$("#JqGrid").jqxGrid(
{
pagesize: 5,
source: dataAdapter,
width: 700,
sortable: true,
pageable: true,
autoheight: true,
columnsresize: true,
filterable: true,
showfilterrow: true,
showtoolbar: true,
footerrow: true,
userDataOnFooter:true,
rendertoolbar: function (toolbar) {
var container = $("<div style='overflow: hidden; position: relative; margin: 3px;'></div>");
var exportButton = $("<div style='float: right; margin-right: 5px;'> <img style='position: relative; margin-top: 2px; width: 16px; height: 16px;' src='images/excel.png' /><span style='margin-left: 4px; position: relative; top: -3px;'>Export to Excel</span></div>");
container.append(exportButton);
toolbar.append(container);
exportButton.jqxButton({ width: 150, height: 20 });
exportButton.click(function (event) {
$("#JqGrid").jqxGrid('exportdata', 'xls', 'Report');
});
},
selectionmode: 'checkbox',
//rendertoolbar: function (toolbar) {
// var container = $("<div style='overflow: hidden; position:relative;margin:3px;'></div>");
// var exportButton = $("<div style='float:right;margin-right:20px;'><img style='position:relative;margin-top:2px;width:16px;height:16px' src='./images/excel.png'/><span style='margin-left:4px;position:relative;top:2px'>Export to Excel</span></div>");
// exportButton.jqxButton({ width: '130' });
// container.append(exportButton);
// toolbar.append(container);
//}
columns: [
{ text: 'VillageName', datafield: 'VillageName', width: 'auto' },
{ text: 'Samples Collected', datafield: 'VillageSamples', width: 'auto' }
],
gridComplete: function () {
calculateTotal();
},
});
var themeSetting = { theme: "darkblue" };
$("#JqGrid").jqxGrid(themeSetting);
var calculateTotal = function () {
var gridData = $("#JqGrid").jqGrid('getGridParam', 'data'),
i = 0, totalAmount = 0, totalTax = 0;
for (; i < gridData.length; i++) {
var rowData = gridData[i];
totalAmount += Number(rowData.VillageSamples);
}
$("#JqGrid").jqGrid('footerData', 'set', { name: 'TOTAL', VillageSamples: totalAmount });
}

Related

SweetAlert2: change font size

I'm trying to replace the sweetalert control with the new sweetalert2 but I've run into some doubts. Among them, I was able to change the width of the popup but not the height. It seems that the "height" property does not take effect.
const { value: causas } = Swal.fire({
title: "Titulo",
text: "Este es el mensaje!",
input: 'select',
type: "warning",
showCancelButton: true,
confirmButtonText: "Confirmar!",
confirmButtonColor: "#DD6B55",
icon: 'warning',
cancelButtonText: "Cancelar!",
closeOnConfirm: true,
closeOnCancel: true,
width: 800,
height: 800,
inputOptions: {
'Causas': {
cause1: 'c1',
cause2: 'c2',
cause3: 'c3',
cause4: 'c4'
}
},
inputPlaceholder: 'Seleccione el item',
showCancelButton: true,
inputValidator: (value) => {
return new Promise((resolve) => {
//if (value === 'oranges') {
// resolve()
//} else {
// resolve('You need to select oranges :)')
//}
})
}
})
if (fruit) {
Swal.fire(`You selected: ${fruit}`)
}
I also want to change the font size but I haven't found how to do it. Maybe I should generate/create a css file? Can you help me? Thank you!!
I just fixed it! I added the properties in the css file.
.swal2-popup {
font-size: 14px !important;
}
.swal2-styled {
padding: 10px 32px 10px 32px !important;
margin: 20px 10px 0px 10px !important;
width: 170px;
height: 45px;
}

Toggle Button doesn't work inside datatable in laravel

The InActive button in the top of the picture, gets displayed properly when it is outside the datatable but doesn't work inside the datatable.
I have added the same code for status column inside the datatable but it displays only a checkbox. How do I get the InActive button inside datatable?
<script type="text/javascript">
$(document).ready(function() {
$.noConflict();
fill_datatable();
function fill_datatable(collegeID = '') {
var table = $('.user_datatable1').DataTable({
order: [
[0, 'desc']
],
processing: true,
serverSide: true,
ajax: {
url: "{{ route('alumni.datatable1') }}",
data: {
collegeID: collegeID
}
},
columns: [{
data: 'id',
name: 'id'
},
{
data: 'name',
name: 'name'
},
{
data: 'status',
name: 'status',
mRender: function(data) {
return ' <input data-id="{{$colleges->id}}" class="toggle-class" type="checkbox" data-onstyle="success" data-offstyle="danger" data-toggle="toggle" data-on="Active" data-off="InActive" {{ $colleges->status ? "checked" : "" }}>'
}
}
},
{
data: 'action',
name: 'action',
orderable: false,
searchable: false
},
]
});
}
});
$(function() {
$('.toggle-class').change(function() {
var status = $(this).prop('checked') == true ? 1 : 0;
var user_id = $(this).data('id');
$.ajax({
type: "GET",
dataType: "json",
url: '/changeStatus',
data: {'status': status, 'id': id},
success: function(data){
console.log(data.success)
}
});
})
})
</script>
Please Add css.....
CSS
<style>
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
You can simple put after status....
Toggle switch
{
"data": "id",
render: function(data, type, row, meta) {
$html = '<label class="switch"> <input type="checkbox">
<span class="slider round"></span></label>';
return $html;
}
},

Show loading gif after submit button is clicked in codeigniter [duplicate]

This question already has answers here:
Show loading gif after clicking form submit using jQuery
(4 answers)
Closed 3 years ago.
How can I show loading GIF in the submit button in Codeigniter?
<button class="btn btn-primary" type="submit" name="save">
<?php echo lang('save'); ?>
</button>
In my CSS file
#btn btn-primary{
position:fixed;
left:0px;
top:width:100%;
height:100%;
z-index:9999;
background:url(images/pageLoader.gif)50% 50% no-repeat rgb(249,249,249);
}
In my JS file:
$('document').ready(function(e){
$("#btn btn-primaryr").fadeout("slow")
try this: do not use image in css give in tag
<img src="<?php url().images/pageLoader.gif?>" id="image">
$('.btn btn-primary').submit(function() {
$('#image').css('visibility', 'visible');
});
You should use like that:
$("#signup-form").submit(function(event) {
event.preventDefault();
var form_data = new FormData($('#signup-form')[0]);
$.ajax({
url : baseURL + "api/signup",
type : "POST",
data : form_data,
dataType : "JSON",
cache: false,
contentType: false,
processData: false,
beforeSend:function(){
ajaxindicatorstart();
},
success: function(resp){
if(resp.resp == 1){
$('#signup-form')[0].reset();
alert(resp.Message);
}else{
alert(resp.Message);
}
ajaxindicatorstop();
},
error:function(error)
{
ajaxindicatorstop();
}
});
});
function ajaxindicatorstart() {
if (
jQuery("body")
.find("#resultLoading")
.attr("id") != "resultLoading"
) {
jQuery("body").append(
'<div id="resultLoading" style="display:none"><div><img src="' +
baseURL() +
'asset/img/ajax-loader.gif"><div>Loading...</div></div><div class="bg"></div></div>'
);
}
jQuery("#resultLoading").css({
width: "100%",
height: "100%",
position: "fixed",
"z-index": "10000000",
top: "0",
left: "0",
right: "0",
bottom: "0",
margin: "auto"
});
jQuery("#resultLoading .bg").css({
background: "#000000",
opacity: "0.7",
width: "100%",
height: "100%",
position: "absolute",
top: "0"
});
jQuery("#resultLoading>div:first").css({
width: "250px",
height: "75px",
"text-align": "center",
position: "fixed",
top: "0",
left: "0",
right: "0",
bottom: "0",
margin: "auto",
"font-size": "16px",
"z-index": "10",
color: "#ffffff"
});
jQuery("#resultLoading .bg").height("100%");
jQuery("#resultLoading").fadeIn(300);
jQuery("body").css("cursor", "wait");
}
function ajaxindicatorstop() {
jQuery("#resultLoading .bg").height("100%");
jQuery("#resultLoading").fadeOut(300);
jQuery("body").css("cursor", "default");
}
Loading Image URL:-
https://pqmsystems.biz/asset/img/ajax-loader.gif
Please try this way....

jqGrid Multiselect does not retrieve data

I have a problem in my multiselect for the code below. While adding new row when I select all items in the list of ‘resources’ column (this field is multiselect with checkbox) and save the row, all data of the row saves correctly to the database. But when the same row is retrieved for editing I see all the items of resources selected except the first one. In the above code I am using bootstrap multiselect plugin. But same is the behaviour when I use eric hynds multiselect plugin. This problem appears to be only with the first item in the list.
<html>
<head>
<title>Maintenance Daily Log</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui.theme.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<link rel='stylesheet' href='css/jquery-ui.css'/>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
<link rel="stylesheet" href="css/bootstrap-multiselect.css" type="text/css"/>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
font-size: 70%;
}
table, th, td {
font-size: 100%;
}
#editmodlist {
font-size: 70%;
}
div#editmodlist {
width: 1000px;
font-size: 130%;
}
.ui-jqgrid {font-size:0.5em;}
div .mce-tinymce {
margin-left: 5px
}
div .mce-btn button, div .mce-menu-item-normal {
font-size: 80%;
}
ul .ui-multiselect-checkboxes {
font-size: 130%;
}
#ui-datepicker-div {
font-size:120%;
}
div .ui-multiselect-header {
font-size: 100%;
}
.ui-multiselect-menu {
font-size: 150%;
width: 100%
}
button .ui-multiselect {
width: 100%;
}
</style>
<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src='js/jquery-ui.min.js'></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="js/tinymce.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-multiselect.js"></script>
<script type="text/javascript">
$(function () {
$("#list").jqGrid({
url:'server.php',
datatype: "json",
mtype: "POST",
colNames: ["SL","Date", "Shift", "Equipment","Resources-1", "Resources", "Works done", "Spares used", "Status"],
colModel: [
{name:'id',index:'id', width:30,classes: 'cvteste', hidden:true},
{ name:'date',index:'date',search: true,searchoptions: {searchhidden: true},editrules:{date:true,required:true},datefmt:'dd-mm-Y', width:70, sortable:false,classes: 'cvteste',editable:true, editoptions:{size:10, dataInit:function(el){
$(el).datepicker({dateFormat:'dd-mm-yy'});
}
}},
{ name:'shift',index:'shift',search: true,searchoptions: {searchhidden: true}, edittype:'select', formatter:'select', editoptions:{value:"G:G;A:A;B:B;C:C"}, width:35,align:"center",classes: 'cvteste',editable:true },
{name:'equipment',index:'equipment',width:110,classes: 'cvteste',editable:true, search: true,searchoptions: {searchhidden: true},edittype:'select', editoptions:{dataUrl:'equipments.php'}},
{name:"resources-1", index:"resources-1",width:105,sortable:false, editable:false},
{name: 'resources', index: 'resources', width: 105, align: 'left', editable: true, formatter: 'select', edittype: 'select', hidden:true, editrules:{edithidden:true}, editoptions: { /*dataUrl: 'resources.php',
postData: function (rowid, value, cmName) {
return {
myId: rowid
}
},*/
dataUrl: function(){
var srow = jQuery("#list").jqGrid('getGridParam','selrow');
var myUrl = "resources.php";
if( srow ) {
myUrl = 'resources.php?myId='+srow;
}
return myUrl;
},
multiselect:true,
dataInit: function (elem) {
setTimeout(function () {
$(elem).multiselect({
//minWidth: 150, //'auto',
// height: "auto",
// selectedList: 2,
// checkAllText: "all",
// uncheckAllText: "no",
// noneSelectedText: "Any",
/*open: function () {
var $menu = $(".ui-multiselect- menu:visible");
$menu.width("auto");
return;
}*/
});
}, 2000);
},
multiple: true
// defaultValue: 'IN'
}
},
{ name: "workdone", index: "workdone", width: 80, sortable: false, editable: true,
//edittype: "textarea"
edittype:'custom',
editoptions: {
custom_element: function (value, options) {
var elm = $("<textarea></textarea>");
elm.val(value);
// give the editor time to initialize
setTimeout(function () {
//tinymce.remove();
//var ctr = $("#" + options.id).tinymce();
//if (ctr !== null) {
// ctr.remove();
//}
try {
tinymce.remove("#" + options.id);
} catch(ex) {}
tinymce.init({selector: "#" + options.id, plugins: "link"});
}, 50);
return elm;
},
custom_value: function (element, oper, gridval) {
var id;
if (element.length > 0) {
id = element.attr("id");
} else if (typeof element.selector === "string") {
var sels = element.selector.split(" "),
idSel = sels[sels.length - 1];
if (idSel.charAt(0) === "#") {
id = idSel.substring(1);
} else {
return "";
}
}
if (oper === "get") {
return tinymce.get(id).getContent({format: "row"});
} else if (oper === "set") {
if (tinymce.get(id)) {
tinymce.get(id).setContent(gridval);
}
}
}}
},
{name:'sparesused',index:'sparesused',search: true,searchoptions: {searchhidden: true}, width:150, sortable:false,classes: 'cvteste',editable:true, editoptions:{size:100}},
{name:'status',index:'status',width:110,classes: 'cvteste',editable:true, search: true,searchoptions: {searchhidden: true},edittype:'select', editoptions:{dataUrl:'status.php'}}
],
pager: "#pager",
rowNum: 10,
rowList: [10, 20, 30],
sortname: "date",
sortorder: "asc",
viewrecords: true,
gridview: true,
autoencode: true,
caption: "Maintenane Daily Log",
editurl: "update.php"
});
$("#list").jqGrid("navGrid", "#pager", {add: true, edit:true}, {closeOnEscape:true, recreateForm: true, width:800},{closeOnEscape:true, recreateForm: true, width:800}
);
});
</script>
</head>
<body>
<div><table id="list"><tr><td></td></tr></table>
<div></div>
</div>
</body>
</html>
and in my resources.php I have as below
<?php
if(isset($_REQUEST['myId']))
{
$rowid=$_REQUEST['myId'];
require_once 'config.php';
$result1 = mysqli_query($con,"SELECT resources FROM worksdata WHERE id=$rowid limit 1") or die(mysql_error());
$row=mysqli_fetch_assoc($result1);
$value = $row['resources'];
$result=mysqli_query($con,"SELECT * FROM resources")
or die(mysql_error());
echo "<select multiple='multiple'>";
while($row=mysqli_fetch_assoc($result))
{
echo '<option value="'.$row['resource'].'"';
if (strpos($value,$row['resource']) !== false)
echo " selected='selected' ";
echo '>';
echo $row['resource'];
echo '</option>';
}
echo "</select>";
}
else
{
require_once 'config.php';
$result=mysqli_query($con,"SELECT * FROM resources")
or die(mysql_error());
echo "<select multiple='multiple'>";
while($row=mysqli_fetch_assoc($result))
{
echo '<option value="'.$row['resource'].'"';
echo '>';
echo $row['resource'];
echo '</option>';
}
echo "</select>";
}
?>
What may be the problem here?

I cannot not go to second window in appcelerator

I am new in Titanium Studio. I am trying to do that when user clicks the any button in window1, it goes the second window. I mean I cannot connect to button1 and button2 in order to pass through the second window.
Here is the my sample code. Can anyone help me please?
Titanium.UI.setBackgroundColor('#000');
var win1 = Ti.UI.createWindow({
layout : 'vertical',
title : 'Welcome to BMI'
});
var button1 = Ti.UI.createButton(
{
title:'Standart',
top : 300,
height: 20,
width: 100
});
button1.addEventListener('click', function(e)
{
win1.close();
win2.open();
});
var button2 = Ti.UI.createButton(
{
title:'Metric',
top : 350,
height: 20,
width: 100
});
button2.addEventListener('click', function(e)
{
win1.close();
win2.open();
});
win1.add(button1);
win1.add(button2);
win1.open();
var win2 = Ti.UI.createWindow({
backgroundColor: 'white',
layout: 'vertical',
title: 'BMI'
});
var label1 = Ti.UI.createLabel({
color: '#900',
font: { fontSize:48 },
shadowColor: '#aaa',
shadowOffset: {x:5, y:5},
text: 'Body Mass Index',
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
top: 30,
width: Ti.UI.SIZE, height: Ti.UI.SIZE
});
var label2 = Ti.UI.createLabel({
color:'blue',
text: 'Welcome to BMI',
textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
top: 30,
width: 300, height: 200
});
win2.add(label1);
win2.add(label2);
I think you should not face problem to execute this code but i think you need to do some modification in your code.
Titanium.UI.setBackgroundColor('#000');
function openNewWin(){
var win2 = Ti.UI.createWindow({
backgroundColor: 'white',
layout: 'vertical',
title: 'BMI'
});
var label1 = Ti.UI.createLabel({
color: '#900',
font: { fontSize:48 },
shadowColor: '#aaa',
shadowOffset: {x:5, y:5},
text: 'Body Mass Index',
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
top: 30,
width: Ti.UI.SIZE, height: Ti.UI.SIZE
});
var label2 = Ti.UI.createLabel({
color:'blue',
text: 'Welcome to BMI',
textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
top: 30,
width: 300, height: 200
});
win2.add(label1);
win2.add(label2);
win2.open({
modal : true
});
}
var win1 = Ti.UI.createWindow({
layout : 'vertical',
title : 'Welcome to BMI'
});
var button1 = Ti.UI.createButton(
{
title:'Standart',
top : 300,
height: 20,
width: 100
});
button1.addEventListener('click', function(e)
{
win1.close();
openNewWin();
});
var button2 = Ti.UI.createButton(
{
title:'Metric',
top : 350,
height: 20,
width: 100
});
button2.addEventListener('click', function(e)
{
win1.close();
openNewWin();
});
win1.add(button1);
win1.add(button2);
win1.open({
modal : true
});

Resources