Column values not changed after edit the coulmn in GRIDX - dojo

Am using Dojo Gridx in my project. These are my columns names
id, field1, field2, active status
I have a assignment, when click column active status need to change the active status value, column icon and field1, field2 values.
For example : if active status values is 'Y' when I click, then I want to change the value of field1, field2 and change active status icon. I can achieve this functionality with the help of below mentioned code.
But here the problem is, field1 is editable, if I click active status column with out edit the field1 the below mentioned code working fine. After I edited, if I click active status column below mentioned code is not working. But values changes in server side, DB side working fine. I don't know what problem please some one make me to understand. I have attached my code for your reference.
require(["dojo/request","dojo/i18n!RW/nls/appResources"], function(request,bundle){
request.get("/RW/rest/"+that.resourcePath,{handleAs : 'J'}).then(
function(J){
that.JGloData=J;
var dataToPopulate = {
identifier: 'id',
items: that.JGloData
};
review.app.defectClassAE.partStore = new dojo.data.ItemFileWriteStore({
data : dataToPopulate
});
review.app.defectClassAE.partStructure = [
{
field : 'id',
name : that.J.defect_id,
width : '5%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{
field : 'field1',
name : that.J.defect_class,
width : '25%',
dataType : 'string',
alwaysEditing : false,
editable : true,
editor : dijit.form.Textarea,
},
{
field : 'field2',
name : that.J.defect_activate_date,
width : '18%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{
field : 'field3',
name : that.J.defect_deactivate_date,
width : '18%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{ field: 'activeStatus', name: bundle.RT_QLIST_ACTIVATE, filterable: false, width: '20%' ,editable : false,
widgetsInCell: true,
decorator: function(){
return "<button data-dojo-type='dijit/form/Button' data-dojo-attach-point='btnactivate' data-dojo-props='showLabel: false' type='button'>Activate</button>";
//return "<div data-dojo-type='dijit.form.Button' data-dojo-attach-point='btnactivate'></div>";
},
setCellValue: function(gridData, storeData, cellWidget){
if(gridData == "Y"){
cellWidget.btnactivate.set('iconClass', "rtIcondeactivateReviewType");
}else{
cellWidget.btnactivate.set('iconClass', "rtIconactivateReviewType");
}
(function(cellWidget){
dojo.connect(cellWidget.btnactivate,"onClick",function(){
//var that = this;
var rawData = cellWidget.cell.row.rawData();
var cell = cellWidget.cell;
var DI="";
var activeStatus="";
DI=rawData.DI;
activeStatus=rawData.activeStatus;
if(DI!=null && DI!=""){
require(["dojo/request","dojo/i18n!RW/nls/appResources"], function(request,bundle){
request.get("/RW/rest/"+that.resourcePath+"/defectActOrDea/"+DI,{handleAs : 'J'}).then(
function(J){
if(activeStatus=='Y' || activeStatus==""){
var deactvalues = {
'activeStatus' : 'N',
'field3':that.getTodayDate(),
'field2':""
};
cell.row.setRawData(deactvalues);
that.set('iconClass', "rtIcondeactivateReviewType");
}
else{
var actvalues = {
'activeStatus' : 'Y',
'field2':that.getTodayDate(),
'field3':""
};
cell.row.setRawData(actvalues);
that.set('iconClass', "rtIconactivateReviewType")
}
},
function(error){
showErrorNotification(that.J.defect_act_deact_error);
}
);
});
}
});
})(cellWidget);
}
},
];

You have to use 'getCellWidgetConnects' for binding events to cell widgets. Also make sure you have your grid model saved after editing.

Related

Error occurs only when initializing more than 1 datatable on a page

I'm trying to have 2 datatables on one page.
I'm not initializing them in one function call, however.
I'm initializing them in separate function calls.
I've made a javascript function that looks like this:
function initialize_datatable(args) {
generate_footer(args.table_selector);
$(args.table_selector).DataTable({
columns: args.columns,
order: args.order,
scrollX: true,
...
...
Is it not possible to call this method twice?
Do I need to consolidate multiple tables into one .DataTable() initialization? E.g. $('#table-one #table-two #table-three').DataTable()?
Whenever I try to make two separate calls to .DataTable() I get the following error:
Uncaught TypeError: Cannot set property 'nTf' of undefined. If you Google this error it says this error occurs because you have a differing number of elements in your header and footer. I have counted my <th> elements in my header footer, they are the same number.
I can initialize one table, or the other, but not both at the same time, so I know it's an issue with making multiple calls to .DataTable()
This is the full definition of initialize_datatable:
function initialize_datatable(args) {
generate_footer(args.table_selector);
$(args.table_selector).DataTable({
columns: args.columns,
order: args.order,
scrollX: true,
sScrollXInner: "100%",
dom: "Blfrtip",
buttons: [
{
extend : 'copyHtml5',
title : args.title,
sheetName : args.title,
footer : true,
exportOptions: {
columns: ':visible'
}
},
{
extend : 'excelHtml5',
footer : true,
title : args.title,
sheetName : args.title,
exportOptions: {
columns: ':visible'
}
},
{
extend : 'csvHtml5',
title : args.title,
sheetName : args.title,
footer : true,
exportOptions: {
columns: ':visible'
}
},
{
extend : 'print',
text : 'Print',
title : args.title,
sheetName : args.title,
autoPrint : true,
footer : true,
stripHtml : false,
exportOptions: {
columns: ':visible',
}
}
],
drawCallback: function () {
let api = this.api();
// hide columns that add up to 0
api.columns().every(function (i) {
let sum = this.data().sum();
if (sum === 0 && typeof sum === 'number' && i !== 0) {
api.column(i).visible(0);
}
});
},
footerCallback: function (row, data, start, end, display) {
let api = this.api()
intVal = function (i) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
}
api.columns({page: 'current'}).every(function (i) {
let columnTotal = this.data().reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
if (!isNaN(columnTotal)) {
columnTotal = Intl.NumberFormat('en-US', {style: 'currency', currency: 'USD'}).format(columnTotal);
$(this.footer()).html(columnTotal);
}
})
}
});
}

Xtemplate shows blank item instead of not showing it with sencha touch 2.1

What i want to do is to show the item of a list of data conditionally,that is , when the item meet the condition,it will show,otherwise,it will not show(not means show a blank item).
My data to be showed is like this :
[
{'label':'one','isvisible':'1','value':'one'},
{'label':'two','isvisible':'1','value':''},
{'label':'three','isvisible':'0','value':'three'},
{'label':'four','isvisible':'0','value':''}
]
And my list is like below:
xtype : 'list',
id : 'myListId',
disableSelection : true,
itemTpl : [
'<tpl if="isvisible == 1 && value !=\'\' ">',
'{label}{value}',
'</tpl>'
]
But when the list showed,i have got some blank rows if the item meets the condition(the property 'visible' is 1 or the property 'value' is empty).
At first,i used '<tpl for="." ' ,I followed this link: link but my list of data have no root node,so i used the itemtpl above.
I do not want to modify the strcuture of my list of data,so how can i do ?
UPDATE:
I do not use a store.I just get the data then assign the data to the data config of the list like:
var data=[{text:'1'},{text:'2'},{text:'3'}];//usually the data array comes from the response of an ajax request to the remote server.
var list=Ext.getCmp('myListId');
list.setData(data);
you can filter the store in your controller, before pushing the list view:
store.filter('isvisible', '1');
http://docs.sencha.com/touch/2.2.1/#!/api/Ext.data.Store-method-filter
EDIT:
initialize: function(list) {
var data = [];
Ext.each(list.getData(), function(rec) {
if (rec.data.isvisible == 1) data.push(rec);
});
list.setData(data);
}
Try this
{
xtype : 'list',
disableSelection : true,
itemTpl : [
'<tpl if="isvisible == 1 && value !=\'\' ">',
'{label}{value}',
'</tpl>'
],
listeners : {
initialize: function(list, eOpts ) {
var visibleFilter = new Ext.util.Filter({
property: 'isvisible',
value : 1
});
var valueFilter = new Ext.util.Filter({
filterFn: function(item) {
return item.data.value.length != 0;
}
});
list.getStore().setFilters([visibleFilter,valueFilter]);
}
}
}

Stop double click action on a action-column

I've a grid panel in extJS 4.1.1. With other columns I've an actioncolumn(xtype:'actioncolumn'). I include a handler with that column. When I click it , it works fine and open a new window with many things loading. But I got error when I double click on that column. Advance welcome for any help.......
{
text : 'Signature',
menuDisabled : true,
sortable : false,
id : 'signature',
xtype : 'actioncolumn',
width : 60,
items : [{
icon : "${resource(dir: 'images', file: 'ADD01003.png')}",
tooltip : 'Add Signature',
scope : this,
handler : function(grid, rowIndex, colIndex) {
var records = grid.getStore().getAt(rowIndex).data,
fullName = records.fullName,
nickName = records.nickName,
salutation = grid.getStore().getAt(rowIndex).raw.m00i012001.name,
searchValue = records.id ;
var filters = new Array();
var store =Ext.data.StoreManager.lookup('S02X004001');
store.clearFilter();
filters.push({property:'member', value:searchValue});
store.loadPage(1, {
filters : filters,
callback : function(records, options, success) {
var view = Ext.widget('v02x004001');
view.show();
Ext.getCmp('fullName-sv02x00400104').setValue(fullName);
Ext.getCmp('nickName-sv02x00400104').setValue(nickName);
Ext.getCmp('member-sv02x00400104').setValue(searchValue);
Ext.getCmp('salutation-sv02x00400104').setValue(salutation);
}
});
}
}]
}
Not to resurrect any Zombies, but for anyone having the same Problem in ExtJS 4, 5 or 6 this workaround should work (maybe the Classnames need to be slightly modified, pasted Code is proven to work in 5.1.1).
The trick is to not modify the actioncolumn but to fix the itemdblclick event handler one might have like so:
listeners:
{
itemdblclick: function(v, record, item, index, e)
{
var flyTarget = Ext.fly(e.target);
if(flyTarget.hasCls('x-action-col-icon') || flyTarget.hasCls('x-grid-cell-inner-action-col'))
{
e.stopEvent();
return;
}
//your code here
}
}

Set focus on form field in extjs when press alert ok button

I want set focus in a number field in extjs when I press alert ok button but i cant do it i try this system. here is my code
Ext.Msg.alert("Invoice",'Invoice Id &nbsp'+invno + '&nbsp is not Available');
Ext.getCmp('InvoiceNo').focus(true);
and my number field is
{
xtype : 'numberfield',
hideTrigger : true,
decimalPrecision : 0,
keyNavEnabled : false,
mouseWheelEnabled : false,
fieldLabel : 'InvoiceNo',
id : 'InvoiceNo',
name : 'InvoiceNo',
enableKeyEvents : true,
//minValue : 1,
msgDisplay : 'tooltip',
anchor : '95%',
}
I can do it by this process.
var v = Ext.getCmp('InvoiceNo').getValue();
Ext.Msg.confirm('InvoiceNo','InvoiceNo'+v , function (button) {
var InvoiceNo = Ext.getCmp('InvoiceNo');
if (button == 'yes') {
setTimeout(function(){
InvoiceNo.setValue(v);
InvoiceNo.focus(true)[0];
},100);
}
}, this);

How to set a value into a openerp form view field from javascript

this is the code i use to call the form view:
get_view_form_dimension: function() {
var self = this;
var action_manager = new openerp.web.ActionManager(this);
var dialog = new openerp.web.Dialog(this, {
width: 800,
buttons : [
{text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }},
{text: _t("Save"), click: function() {
var form_view = action_manager.inner_viewmanager.views.form.controller;
form_view.do_save(function() {
$.jstree._reference("#new_tree").destroy();
self.get_tree_structure();
});
$(this).dialog('destroy');
}}
]
}).open();
action_manager.appendTo(dialog.$element);
action_manager.do_action({
res_model : 'df.bi.dimension',
res_id: self.process_id,
views : [[false, 'form']],
type : 'ir.actions.act_window',
flags : {
search_view: false,
sidebar : false,
views_switcher : false,
action_buttons : false,
pager: false
}
});
},
how can i set values into the form that this method will rise ?? or in case that exist other solution please tell me ? sorry for my english!
Add a context field to your do_action call with default values, like this:
context: {'default_account_id': 5, 'default_name': 'hello'},