Animated (slide) transition in sencha touch - animation

I have a panel in a sencha app swich contains a login form. The think is that I wanna load new content when the form is submited. I wanna that the new content is loaded after an slide animation. I tried to use mainPanel.setCard({type:'slide'}) but it I don't know how to put the new content. Any idea?
Ext.setup({
icon: 'icon.png',
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
glossOnIcon: false,
onReady: function() {
var mainPanel = new Ext.Panel({
id:'main-panel',
renderTo: 'content',
html: '<h1>Please Identify:</h1><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vel neque nec mauris eleifend fringilla. Nulla sagittis placerat ullamcorper. Duis ac elit sapien. Pellentesque semper vestibulum leo id vehicula.</p>'
});
var form;
Ext.regModel('User', {
fields: [
{
name: 'name',
type: 'string'
},
{
name: 'password',
type: 'password'
},
]
});
var formBase = {
renderTo:'main-panel',
id: 'login-form',
url : 'resources/login.php',
standardSubmit : false,
items: [{
xtype: 'fieldset',
defaults: {
required: true,
labelAlign: 'left',
labelWidth: '40%'
},
items: [
{
xtype: 'textfield',
name : 'username',
label: 'Usuario',
useClearIcon: true,
autoCapitalize : false
}, {
xtype: 'passwordfield',
name : 'password',
label: 'Contraseña',
useClearIcon: false
}
]
}
],
listeners : {
submit : function(form, result){
console.log('success', Ext.toArray(arguments));
},
exception : function(form, result){
console.log('failure', Ext.toArray(arguments));
}
},
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
items: [
{
text: 'Entrar',
id: 'login-submit',
ui: 'confirm',
handler: function() {
form.submit({
method:'POST',
waitTitle:'Connecting',
waitMsg:'Sending data...',
success:function(response){
Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
if (btn == 'ok'){
mainPanel.setCard({
type: 'slide'
});
}
});
},
failure:function(form, action){
Ext.Msg.alert('Status', 'Login Failed!', function(btn, text){
if (btn == 'ok'){
form.reset();
}
});
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Login Failed!', obj.errors.reason);
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
}
form.reset();
}
});
}
}
]
}]
};
Ext.apply(formBase, {
height: 150,
width: 300
});
form = new Ext.form.FormPanel(formBase);
form.show();
}
});

the correct code should be :
Ext.get('main-panel').setActiveItem(1, {type : 'slide', direction:'left'});

Related

highcharts - drilldown: does not workn with AJAX

I have a chart below that does not work with AJAX request.
function ajaxGraficoBarraUnidade() {
var strSeries = "";
var strDrilldown = "";
$.ajax({
type: "POST",
data: window.formData + '&strMundo=' + "<?php echo ($strMundo); ?>" + '&strGraph=Unidade',
dataType: "json",
url: "ajaxBlitzCarregamentoGrafico.php",
beforeSend: function () {
},
success: function (strRetorno) {
strSeries = strRetorno.geos;
strDrilldown = strRetorno.unidades;
carregaGraficoBarraUnidade(strSeries, strDrilldown);
},
error: function (txt) {
}
});
}
function carregaGraficoBarraUnidade(strSeries, strDrilldown) {
$('#divGraficoBarraUnidade').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Browser market shares. January, 2015 to May, 2015'
},
subtitle: {
text: 'Click the columns to view versions. Source: netmarketshare.com.'
},
xAxis: {
type: 'category'
},
yAxis: {
title: {
text: 'Total percent market share'
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: strSeries,
drilldown: {
series: strDrilldown
}
});
</code>
I have a return equal to ajax below:
{'geos':[{'name': 'Regionais','data': [{'name':'Geo CO','y':1.59,'drilldown':'Geo CO'},{'name':'Geo MG/ES','y':4.41,'drilldown':'Geo MG/ES'},{'name':'Geo NE','y':3.35,'drilldown':'Geo NE'},{'name':'Geo NO','y':1.96,'drilldown':'Geo NO'},{'name':'Geo PR/SPI','y':0.10,'drilldown':'Geo PR/SPI'},{'name':'Geo RJ','y':1.81,'drilldown':'Geo RJ'},{'name':'Geo RS/SC','y':0.75,'drilldown':'Geo RS/SC'},{'name':'Geo SPC','y':0.33,'drilldown':'Geo SPC'}]}], 'unidades':[{'name':'Geo CO','id':'Geo CO','data': [['CDC Araguaina',1.30],['CDC Catalao',0.01],['CDC Formosa',4.70],['CDC Porto Velho',0.29],['CDC Rio Branco',0.00],['CDC Rio Verde',0.12],['CDC Rondonopolis',5.15],['CDC Tangara',0.51],['CDD Brasilia',0.06],['CDD Brasilia Int',2.67],['CDD Caceres',0.05],['CDD Campo Gde',0.00],['CDD Cuiaba Int',0.03],['CDD Goiania Int',0.00],['CDD Itumbiara',38.19],['CDD Manaus',0.43]]},{'name':'Geo MG/ES','id':'Geo MG/ES','data': [['CDD Alfenas',0.02],['CDD Cachoeiro',0.28],['CDD Ipatinga',0.03],['CDD João Monlevade DDC',0.00],['CDD Minas Int',0.77],['CDD Poços de Caldas',0.91],['CDD Pouso Alegre',0.17],['CDD Uberaba',0.08],['CDD Uberlandia',0.07],['CDD Vitoria',25.62],['CDL AS Minas',0.01],['CDL Santa Luzia',2.70]]},{'name':'Geo NE','id':'Geo NE','data': [['CDC Arapiraca',0.12],['CDC Lapa',0.32],['CDD Aracaju',0.05],['CDD Caruaru',8.05],['CDD F. de Santana',0.17],['CDD Guanambi',0.01],['CDD Ilheus',0.03],['CDD Maceio',0.06],['CDD Olinda',0.16],['CDD Rib. Pombal',0.04],['CDD Salvador',0.17],['CDD Vit. da Conquista',0.06],['CDL Cabo',1.33],['CDL Jequie',0.06]]},{'name':'Geo NO','id':'Geo NO','data': [['CDD Aracati',0.02],['CDD Balsas',0.08],['CDD Belem',0.02],['CDD Campina Grande',0.03],['CDD Fortaleza',0.03],['CDD Imperatriz',0.02],['CDD Joao Pessoa Int',5.86],['CDD Maranhao Int ',12.72],['CDD Natal Int',0.02],['CDD Sul Maranhão',0.03],['CDL Ceara',0.37]]},{'name':'Geo PR/SPI','id':'Geo PR/SPI','data': [['CDC Beltrao',0.00],['CDD Agudos Int',0.12],['CDD Araçatuba',0.07],['CDD Araraquara',0.02],['CDD Bebedouro',0.09],['CDD Curitiba',0.00],['CDD Jaú',3.19],['CDD Londrina',0.00],['CDD Mogi Mirim',0.04],['CDD Ponta Grossa',0.37],['CDD Presidente Prudente',0.05],['CDD Rib. Preto',0.04],['CDL Paranagua',0.02]]},{'name':'Geo RJ','id':'Geo RJ','data': [['CDD Campos',1.18],['CDD Jacarepagua',1.65],['CDD Niteroi',0.02],['CDD Nova Friburgo',0.01],['CDD Nova Iguacu',0.02],['CDD Petropolis',0.00],['CDD RJ Campo Gde Int',3.77],['CDD S. Cristovao',0.81],['CDL Itaperuna',0.14]]},{'name':'Geo RS/SC','id':'Geo RS/SC','data': [['CDD Blumenau',0.07],['CDD Camboriu',0.11],['CDD Caxias do Sul',0.07],['CDD Florianopolis',0.12],['CDD Pelotas',0.04],['CDD Porto Alegre',1.06],['CDD S. Cruz Sul',0.02],['CDD Santa Maria',0.45],['CDD Sapucaia Int',2.66]]},{'name':'Geo SPC','id':'Geo SPC','data': [['CDD Campinas',0.12],['CDD Diadema',0.72],['CDD Guarulhos',0.23],['CDD Jundiai',1.04],['CDD Litoral SP',0.05],['CDD Mooca',1.05],['CDD Norte',0.10],['CDD Oeste',0.04],['CDD Praia Grande',0.06],['CDD São José dos Campos',0.54],['CDD Sul SP',0.00],['CDD Taubaté',0.82],['CDD Votorantin',0.77]]}]}
It does not recognize the values passed in SERIES. I do not think the error. Does anyone know what might be happening? Tanks!
What might be happening is your data is getting loaded after the chart is created, so I've changed the format to be as shown in the Highcharts documentation, but tried not to change to much otherwise.
Highcharts documentation on working with data
See a plunkr demo with your chart working with available data
The data is hosted on myjson.com as JSON, so I changed the POST to a GET request.
Here is the key HTML code:
<script src="https://code.jquery.com/jquery-3.0.0.min.js" integrity="sha256-JmvOoLtYsmqlsWxa7mDSLMwa6dZ9rrIdtrrVYRnDRH0=" crossorigin="anonymous"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="divGraficoBarraUnidade" style="width:100%; height:400px;"></div>
This is the Javascript / jQuery code:
$(function () {
$(document).ready(function() {
var options = {
chart: {
renderTo: 'divGraficoBarraUnidade',
type: 'column'
},
title: {
text: 'Browser market shares. January, 2015 to May, 2015'
},
subtitle: {
text: 'Click the columns to view versions. Source: netmarketshare.com.'
},
xAxis: {
type: 'category'
},
yAxis: {
title: {
text: 'Total percent market share'
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: {},
drilldown: {
series: {}
}
};
function ajaxGraficoBarraUnidade() {
$.ajax({
type: "GET",
data: window.formData + '&strMundo=' + "<?php echo ($strMundo); ?>" + '&strGraph=Unidade',
dataType: "json",
url: "https://api.myjson.com/bins/42c59",
beforeSend: function () {
},
success: function (strRetorno) {
options.series = strRetorno.geos;
options.drilldown.series = strRetorno.unidades;
var chart = new Highcharts.Chart(options);
console.log('options', options)
},
error: function (txt) {
// Report errors here...
}
});
}
ajaxGraficoBarraUnidade();
});
});

How to send data to the controller from the Kendo UI TreeView

I have two TreeViews, one has a list of countries, and the other is empty, now I want drag and drop selected countries into the second tree-view. I don't know how to send data to the controller from the TreeView and there is also some text field on the page in a form. So, how can I send both the form data and the TreeView's data to the controller.
Here is the code for the second tree-view which is empty and I want to add the selected nodes to:
#(Html.Kendo().TreeView()
.Name("treeview-right")
.DragAndDrop(true)
.Events(events => events
.Drag("onDrag")
.Drop("onDrop")
)
)
Please try with the below code snippet.
HTML/VIEW
<div style="border: 1px solid green;">
<div id="treeview-left"></div>
</div>
<div style="border: 1px solid red;">
<div id="treeview-right"></div>
</div>
<div id="mydiv" onclick="SaveData()">Click me to save data</div>
<script>
$("#treeview-left").kendoTreeView({
dragAndDrop: true,
dataSource: [
{
id: 11, text: "Furniture", expanded: true, items: [
{ id: 12, text: "Tables & Chairs" },
{ id: 13, text: "Sofas" },
{ id: 14, text: "Occasional Furniture" }
]
},
{
id: 15, text: "Decor", items: [
{ id: 16, text: "Bed Linen" },
{ id: 17, text: "Curtains & Blinds" },
{ id: 18, text: "Carpets" }
]
}
]
});
$("#treeview-right").kendoTreeView({
dragAndDrop: true,
dataSource: [
{
id: 1, text: "Storage", expanded: true, items: [
{ id: 2, text: "Wall Shelving" },
{ id: 3, text: "Floor Shelving" },
{ id: 4, text: "Kids Storage" }
]
},
{
id: 5, text: "Lights", items: [
{ id: 6, text: "Ceiling" },
{ id: 7, text: "Table" },
{ id: 8, text: "Floor" }
]
}
]
});
var selectedID;
function SaveData() {
selectedID = '';
var tv = $("#treeview-right").data("kendoTreeView");
selectedID = getRecursiveNodeText(tv.dataSource.view());
alert(selectedID);
var data = {};
data.str = selectedID;
$.ajax({
url: 'Home/SaveData',
type: 'POST',
data: data,
dataType: 'json',
success: function (result) {
alert("Success");
},
error: function (result) {
alert("Error");
},
});
}
function getRecursiveNodeText(nodeview) {
for (var i = 0; i < nodeview.length; i++) {
selectedID += nodeview[i].id + ",";
//nodeview[i].text; You can also access text here
if (nodeview[i].hasChildren) {
getRecursiveNodeText(nodeview[i].children.view());
}
}
return selectedID;
}
</script>
CONTROLLER
namespace MvcApplication2.Controllers
{
public class HomeController : Controller
{
[HttpPost]
public JsonResult SaveData(string str)
{
foreach (string s in str.Split(','))
{
if (!string.IsNullOrEmpty(s))
{
//Perform your opeartion here
}
}
return Json("");
}
}
}
jsfiddle Demo

Why does the KendoUI Grid not rollback a delete when the options.error function is called?

I have put a fiddle here that demonstrates the issue.
http://jsfiddle.net/codeowl/fmzay/1/
Just delete a record, and it should rollback the delete as I am calling options.error from inside the destroy function.
Why is it that the grid doesn't roll back?
Regards,
Scott
Markup:
<div id="KendoGrid"></div>
JS:
var _data = [
{ Users_ID: 1, Users_FullName: 'Bob Smith', Users_Role: 'Administrator' },
{ Users_ID: 2, Users_FullName: 'Barry Baker', Users_Role: 'Viewer' },
{ Users_ID: 3, Users_FullName: 'Bill Cow', Users_Role: 'Editor' },
{ Users_ID: 4, Users_FullName: 'Boris Brick', Users_Role: 'Administrator' }
],
_dataSource = new kendo.data.DataSource({
data: _data,
destroy: function (options) {
options.error(new Error('Error Deleting User'));
}
});
$('#KendoGrid').kendoGrid({
dataSource: _dataSource,
columns: [
{ field: "Users_FullName", title: "Full Name" },
{ field: "Users_Role", title: "Role", width: "130px" },
{ command: ["edit", "destroy"], title: " ", width: "180px" }
],
toolbar: ['create'],
editable: 'popup'
});
Signaling the error is not enough. Lets say that having an error on removing a record is not enough since KendoUI doesn't know if the record has actually been removed in the server and the reply is the one producing the error. So KendoUI approach is a conservative approach: You have to decide what to do and explicitly say it:
So what you should do is add an error hander function that invokes a cancelChanges in the grid.
The code would be:
_dataSource = new kendo.data.DataSource({
transport: {
read: function(options) {
options.success(_data);
console.log('Read Event Has Been Raised');
},
destroy: function (options) {
options.error(new Error('Error Deleting User'));
console.log('Destroy Event Has Been Raised');
}
},
schema: {
model: {
id: "Users_ID",
fields: {
Users_ID: { editable: false, nullable: true },
Users_FullName: { type: "string", validation: { required: true } },
Users_Role: { type: "string", validation: { required: true } }
}
}
},
error: function(a) {
$('#KendoGrid').data("kendoGrid").cancelChanges();
}
});
And the updated JSFiddle in here: http://jsfiddle.net/OnaBai/fmzay/3
The ASP.NET-MVC equivalent solution to the OnaBai answer would be:
<script type="text/javascript">
function cancelChanges(e) {
e.sender.cancelChanges();
}
</script>
#Html.Kendo().Grid<MyClass>()
.DataSource(dataSource =>
dataSource
.Ajax()
.Read(read => read.Action("Read", "MyController"))
.Destroy(destroy => destroy.Action("Destroy", "MyController"))
.Events(evt => evt.Error("cancelChanges"))
)
[...]
Please be aware that the cancelChanges event will be called upon an error on every CRUD request.

kendoAutoComplete shows [object object] when clicked on template or item

This code return the result below in snaps.
How to populate text field with FirstName and LastName when click on template instead of [object object] ?
function forAutoComplete(FieldName){
var autoCompleteUsers = $("#employees").kendoAutoComplete({
minLength: 1,
dataTextField: FieldName,
template: '<div style="border-bottom: 1px solid DARKGRAY; padding:10px 0; clear:both;">' +
'<img style="float:left; margin-right:20px;" width=\"127\" height=\"127\" src=\"<?php echo base_url() ?>/user_uploads/employee_images/${data.Photo}\" alt=\"${data.Photo}\"/>'+
'<div style="display: inline-block;"><p>${ data.FileNo}</p>' +
'<h3>${ data.FirstName } ${ data.LastName }</h3></div>'+
'<div style="clear: both; "></div></div>',
dataSource: {
serverFiltering: true,
transport: {
read: {
type: "GET",
dataType: "json",
contentType:'application/json; charset=utf-8',
url: "<?php echo base_url() ?>index.php/hr_management/manage_hr/search_employee/",
data: function (arg){
return {FieldName : autoCompleteUsers.data("kendoAutoComplete").value()};
}
}
}
},
height: 300,
change: onChangeAutoComplete
});
}
The problem is likely to be related with the value that you set for dataTextField.
Doing some-sort-of-reverse-engineering, I guess that the JSON data that you return is something like:
[
{data: { FileNo: "0001", FirstName: "OnaBai", LastName: "it's me", Photo: "https://si0.twimg.com/profile_images/2648375258/7f7e451f0de1eb467fe35f4f481d7bf7_bigger.jpeg" } },
{data: { FileNo: "0002", FirstName: "Burke", LastName: "Holland", Photo: "https://si0.twimg.com/profile_images/3342899483/51e933d69222ce8ad8cd14e655116959.jpeg" } },
{data: { FileNo: "0003", FirstName: "Todd", LastName: "Anglin", Photo: "https://si0.twimg.com/profile_images/1478082886/todd-anglin-close-up_illustrated.png" } }
]
If so, you should be defining it as data.FirstName.
If you are defining it as:
[
{ FileNo: "0001", FirstName: "OnaBai", LastName: "it's me", Photo: "https://si0.twimg.com/profile_images/2648375258/7f7e451f0de1eb467fe35f4f481d7bf7_bigger.jpeg" },
{ FileNo: "0002", FirstName: "Burke", LastName: "Holland", Photo: "https://si0.twimg.com/profile_images/3342899483/51e933d69222ce8ad8cd14e655116959.jpeg" },
{ FileNo: "0003", FirstName: "Todd", LastName: "Anglin", Photo: "https://si0.twimg.com/profile_images/1478082886/todd-anglin-close-up_illustrated.png" }
]
Then it should be just FirstName.
Example of the first approach in here while second in here
If you define dataTextField: "data", and use the first approach for your JSON then you get the [object Object]. See it here

jqgrid dataevent does not trigger for dynamically-loaded data in dropdown

Here is multiple select for Size, which is filled on the basis of a style value. Initially it's empty.
When I change any selection of Size, the dataevent change not trigger. What am I doing incorrectly here?
<script language="javascript" type="text/javascript">
function setHiddensizes(e)
{
var sizesId = $(e.target).val();
var row = $(e.target).closest('tr.jqgrow');
var rowId = row.attr('id');
$("#" + rowId +"_sizesId").val(sizesId);
}
var i = 1;
var lastSelection=0;
$(function()
{
$("#curruntppeGridgrid").jqGrid({
url:'getcostperformancecurreuntPPE',
datatype: "json",
jsonReader:{"repeatitems":false,unformat:Unformat_Select},
colNames:['Action','surveyId','applicationId','CategoryId','ManufacturerId','StyleId','UOMId','averagelifetimeselectId','sizesId','vp2Id','gridid',
'recordId','Category','Manufacturer','Style','UOM','Count','Unit','Qty','Cost','Sizes','Annual Cost','VP2'],
colModel:[{name:'id',index:'id',hidden:true,key:true},
{name:'surveyId',index:'surveyId',hidden:true,editable:true},
{name:'applicationId',index:'applicationId',hidden:true,editable:true},
{name:'categoryId',index:'categoryId',hidden:true,editable:true},
{name:'manufacturerId',index:'manufacturerId',hidden:true,editable:true},
{name:'styleId',index:'styleId',hidden:true,editable:true},
{name:'uomId',index:'uomId',hidden:true,editable:true},
{name:'averagelifetimeselectId',index:'averagelifetimeselectId',hidden:true,editable:true},
{name:'sizesId',index:'sizesId',hidden:true,editable:true},
{name:'vp2Id',index:'vp2Id',hidden:true,editable:true},
{name:'gridId',index:'gridId',hidden:true,editable:true,editoptions:{defaultValue:'current'}},
{name:'recordId',index:'recordId',hidden:true,editable:true},
{name:'category',index:'category',align:'center',editable: true, hidden: false, edittype: 'select',
editoptions: { multiple: false, value: eval('(' + catList + ')'),
dataEvents: [{
type: 'change',
fn:function(e){
loadStyle(e);
}}]},
editrules: {required:false,custom:true,custom_func:categorycheck}
},
{name:'manufacturer',index:'manufacturer',align:'center', editable: true, hidden: false, edittype: 'select',
editoptions: { value:eval('(' + manufList + ')'),
dataEvents: [{
type: 'change',
fn:function(e){
loadStyle(e);
}}]},
editrules: {required:false}
},
{name:'style',index:'style',align:'center',editable: true, hidden: false, edittype: 'select',
editoptions: { multiple: false, value: eval('('+styleList+')'),
dataInit: function (elem) {
var v = $(elem).val();
if(v!='')
{
var data = loadSizes(elem);
jQuery('#curruntppeGridgrid').setColProp('sizes',{editoptions:{multiple:true,value:data}});
var data1 = loadUom(elem);
jQuery('#curruntppeGridgrid').setColProp('uom',{editoptions:{value:data1}});
}
else
{
jQuery('#curruntppeGridgrid').setColProp('sizes',{editoptions:{multiple:true,value:{}}});
jQuery('#curruntppeGridgrid').setColProp('uom',{editoptions:{value:{}}});
}
},
dataEvents: [{
type: 'change',
fn:function(e){
loadCategoryAndManufacturer(e);
}}]
},
editrules: { required: true}},
{name:'uom',index:'uom',align:'center', editable: true, hidden: false, edittype: 'select',
editoptions: { multiple: false, value:eval('(' + uomfList + ')'),
dataEvents: [{
type: 'change',
fn:function(e){
setHiddenUom(e);
}}]
},
editrules: { required: false }},
{name:'averagelifetime',index:'averagelifetime',editable:true,align:'center',sortable:false,editrules:{integer:true},
editoptions:{class:'validate[custom[numbersOnly]]',
dataEvents: [{
type: 'click',
fn:function(e){
$('#formQuickSurvey').validationEngine({promptPosition:'bottomLeft',validationEventTrigger:'keyup'});
}
},
{
type: 'change',
fn:function(e){
setQty(e);
}
}
]}
},
{name:'averagelifetimeselect',index:'averagelifetimeselect',editable:true,align:'center',edittype: 'select',
editoptions:{ multiple: false, value: eval('(' + avglifetimelist + ')'),
dataInit: function (elem) {
var v = $(elem).val();
if(v!=''){
jQuery('#curruntppeGridgrid').setColProp('averagelifetimeselectId', { editoptions: { defaultValue:v}} );
}
},
dataEvents: [{
type: 'change',
fn:function(e){
setHiddenaveragelifetimeselect(e);
setQty(e);
}}]
},
editrules: { required: false }},
{name:'qty',index:'qty',align:'center',editable:true,editrules:{integer:true},
editoptions:{class:'validate[custom[numbersOnly]]',
dataEvents: [{
type: 'change',
fn:function(e){
calculateannualCost(e);
}
},{
type:'click',
fn:function(e){
$('#formQuickSurvey').validationEngine({promptPosition:'bottomLeft',validationEventTrigger:'keyup'});
}
}]
}
},
{name:'cost',index:'cost',align:'center',editable:true,editrules:{number:true},
editoptions:{class:'validate[custom[number]]',
dataEvents: [{
type: 'change',
fn:function(e){
calculateannualCost(e);
}
},{
type:'click',
fn:function(e){
$('#formQuickSurvey').validationEngine({promptPosition:'bottomLeft',validationEventTrigger:'keyup'});
}
}]
}
},
{name:'sizes',index:'sizes',align:'center',edittype:'select',editable:true,editoptions:{multiple:true,value:{},
dataInit: function (elem) {
var v = $(elem).val();
if(v!=''){
jQuery('#curruntppeGridgrid').setColProp('sizesId', { editoptions: { defaultValue:v}} );
}
},
dataEvents: [{
type: 'change',
fn:function(e){
setHiddensizes(e);
}}]
}
},
{name:'annualCost',index:'annualCost',align:'center',editable: true, editoptions: { readonly: 'readonly' }},
{name:'vp2',index:'vp2',align:'center',editable: true, hidden: false, edittype: 'select',
editoptions: { multiple: false, value: eval('(' + vp2fList + ')'),
dataInit: function (elem) {
var v = $(elem).val();
if(v!=''){
jQuery('#curruntppeGridgrid').setColProp('vp2Id', { editoptions: { defaultValue:v}} );
}
},
dataEvents: [{
type: 'change',
fn:function(e){
setHiddenvp2(e);
validateCategoryandVP2(e);
}}]
},
editrules: { required: false }}
],
cmTemplate:{sortable:false},
width: eval('gridWidth()'),
pgbuttons:false,
pginput:false,
viewrecords:false,
//pager: '#curruntppeGridpager',
toppager:true,
multiselect:true,
editurl: 'editsurveyppe',
caption: 'Current PPE',
//forceFit:true,
hiddengrid:true,
hidegrid:true,
headertitles:true,
postData: { appId: function() { return $('#selectApplication option:selected').val(); }
},
onHeaderClick : function(gridstate){
if(gridstate == 'visible'){
$("#curruntppeGridgrid_toppager").show();
}
else{
$("#curruntppeGridgrid_toppager").hide();
}
},
loadComplete: function() {
$('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button after record reload
if(jQuery('#curruntppeGridgrid').jqGrid('getGridParam','gridstate')!='visible')
{
$("#curruntppeGridgrid_toppager").hide();
}
else{
$("#curruntppeGridgrid_toppager").show();
}
/* if($("#${gridId}grid").getGridParam("records")==0 || $("#${gridId}grid").getGridParam("records")==false)
{
$('#del_${gridId}grid').addClass('ui-state-disabled');
$('#${gridId}grid_iledit').addClass('ui-state-disabled');
}
else
{
$('#del_${gridId}grid').removeClass('ui-state-disabled');
$('#${gridId}grid_iledit').removeClass('ui-state-disabled');
};*/
},
afterInsertRow:function(){//this is added to disable delete button while adding record
$('#del_curruntppeGridgrid_top').addClass('ui-state-disabled');
/*if($('#del_${gridId}grid').hasClass('ui-state-disabled'))
{
}*/
}
,ajaxSelectOptions: { cache: false }
});
jQuery("#curruntppeGridgrid").jqGrid('navGrid',"#curruntppeGridpager",{cloneToTop:true,position:'right',edit:false,add:false,del:true,search:false,refresh:true,pgbuttons:false},
{},{},{mtype:'POST',reloadAfterSubmit:true,
serializeDelData: function (postdata) {
var row = jQuery('#curruntppeGridgrid').getRowData(postdata.id);
// append postdata with extra information
return {id: postdata.id, oper: postdata.oper,gridId:'current'};
}},{});
//top toolbar
jQuery("#curruntppeGridgrid").jqGrid('inlineNav','#curruntppeGridgrid_toppager',
{position:'right',editParams : {aftersavefunc:function()
{
$("#curruntppeGridgrid").jqGrid().trigger("reloadGrid");
$('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button after saveing record
},oneditfunc: function() {
$('#del_curruntppeGridgrid_top').addClass('ui-state-disabled');//this is added to disable delete button while editing record
},
afterrestorefunc :function() {
$('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button while cancelling record
/*if($("#${gridId}grid").getGridParam("records")==0 || $("#${gridId}grid").getGridParam("records")==false)
{
$('#del_${gridId}grid').addClass('ui-state-disabled');
$('#${gridId}grid_iledit').addClass('ui-state-disabled');
}
else
{
$('#del_${gridId}grid').removeClass('ui-state-disabled');
$('#${gridId}grid_iledit').removeClass('ui-state-disabled');
};*/
}
,extraparam:{
currentApplicationId: function() { return $("#selectApplication option:selected").val(); }
}
},
"restoreAfterSelect":false
});
jQuery('#curruntppeGridgrid').jqGrid('setGroupHeaders',{
useColSpanStyle: true,
groupHeaders:[{
startColumnName: 'averagelifetime',
numberOfColumns: 2,
titleText: '<em>Average Lifetime</em>'
}
]});
});
</script>
<div id="curruntppeGridContainer" class="pad7 ansellGridContainer">
<table id="curruntppeGridgrid" class="ansellGrid"></table>
<div id="curruntppeGridpager" class="scroll" style="text-align:center;"></div>
</div>
<div id="curruntppeGriddialog" title="Feature not supported"
style="display:none">
<p>
That feature is not supported.
</p>
</div>
<div id="curruntppeGriddialogSelectRow" title="Warning" style="display:none">
<p>
Please select row
</p>
</div>

Resources