I have a popup in which I have a dropdown. When I change the value of the dropdown to some other value it shows the orange triangle of the dirty check, but if I change the value of the drop down back to the previous value, the dirty check mark is still shown.
If the value is changed back to the original value in the dropdown, I want the dropdown to not show the dirty check mark.
Sharing my code
columns: {
defaults: {
align: 'left',
flex: 2
},
items: [{
xtype: 'actioncolumn',
localized: {
text: 'commonTranslations.function'
},
items: [{
iconCls: 'iwp-icon-gen_edit',
handler: 'onEditClick',
getTip: function() {
return I18n.get('commonIconTranslations.penReleaseConcepts')
}
}],
align: 'center',
flex: 1
},
{
localized: {
text: 'commonTranslations.description'
},
dataIndex: 'title',
renderer: CommonRendererUtils.htmlEncode
},
{
localized: {
text: 'commonTranslations.fileName'
},
dataIndex: 'filename',
renderer: CommonRendererUtils.htmlEncode
},
{
xtype: 'actioncolumn',
localized: {
text: 'commonTranslations.file'
},
items: [{
getClass: function(v, metadata, r) {
if (!r.get('filename')) {
return 'x-hidden'
} else {
return 'iwp-icon-zeb_folder'
}
},
getTip: function() {
return I18n.get('commonIconTranslations.halfOpenFolder')
},
handler: 'onDownloadClick'
}],
align: 'center',
flex: 1
},
{
localized: {
text: 'commonTranslations.source'
},
dataIndex: 'source',
flex: 1
},
{
localized: {
text: 'details.tabview.scope.contents.release.main.uploadDate'
},
dataIndex: 'changeDate',
xtype: 'dynamicTimestampColumn'
},
{
localized: {
text: 'details.tabview.scope.contents.release.main.uploadBy'
},
dataIndex: 'changeUser',
xtype: 'usercolumn'
},
{
localized: {
text: 'commonTranslations.status'
},
/*-----facing issue for the column*/
dataIndex: 'status',
renderer: function(value) {
return value.germanDescription;
}
},
{
localized: {
text: 'commonTranslations.changeReason'
},
dataIndex: 'changeReason',
renderer: CommonRendererUtils.htmlEncode
},
{
localized: {
text: 'commonTranslations.modulOrg'
},
dataIndex: 'modulOrgs',
renderer: function(value, metaData, record) {
if (record.isModified(metaData.column.dataIndex)) {
console.log("modified 9999999" + record.isModified(metaData.column.dataIndex));
metaData.tdCls += 'x-grid-dirty-cell';
}
var formattedValue = "";
if (value) {
value.forEach(function(modulOrg) {
formattedValue += modulOrg.modulOrg + ", ";
});
}
return formattedValue.substring(0, formattedValue.length - 2);
},
flex: 1
},
{
localized: {
text: 'details.tabview.scope.contents.release.main.historyIndex'
},
dataIndex: 'historyIndex',
flex: 1
}
]
}
I think you have too much code for this. Anyways there is a change event listener that you can add to your dropdown as follows:
listeners:{
change:'combochange'
}
Now you can write this combochange function inside your controller or you can defined this function inside your view only.
combochange:function(field,newValue,oldValue,e){
// Inside this function you will get both the values of the dropdown of
yours where newValue is the value currently selected and oldValue is the
previous value. So inside this function according to your conditions you
can put a check that if the old and newvalue matches then not to show the
orange triangle.
}
Let me know if any issue. Happy Learning :)
Related
I have grid panel, its having check all options. But I'm stuck on the selected dataIndex which having value = 'N'. There is Y or N. If some rows having value N, it must not check when I click check all. I had already make validation on it. it's work. But I want also the uncheck is appear when i click check all if it's value is 'N'. This is my code
var sm;
sm = Ext.create('Ext.selection.CheckboxModel');
gridMain = Ext.create('Ext.grid.Panel', {
id: 'gridMyapproval',
renderTo: Ext.get("sa-grid"),
store: 'myapproval-store',
selModel: sm,
height: mainContentHeight - 63, //480//mainContentHeight-138,
//title: 'Request',
columns: [{
text: 'Request Type',
width: 100,
dataIndex: 'WorkflowType'
}, {
text: 'Requestor ID',
width: 100,
dataIndex: 'RequestedByID'
}, {
text: 'Requestor Name',
width: 200,
dataIndex: 'RequestedByName'
}, {
text: 'Description',
flex: 1,
dataIndex: 'RequestDescription'
}, {
text: 'Status',
width: 150,
dataIndex: 'RequestStatusDescription'
},
{
text: 'EnableApprove',
width: 150,
dataIndex: 'EnableApprove'
},
],
dockedItems: [{
xtype: 'toolbar',
items: [actApproveAll]
}],
listeners: {
itemdblclick: function (view, record, item, index, e, eOpts) {
isGridClicked = true;
ViewDetails(FormState.VIEW);
},
afterrender: function (row, model, index) {
//$('.x-column-header-checkbox').css('display','none');
if (model.data.EnableApprove == 'N') {
grid.getSelectionModel().deselect();
}
},
selectionchange: function (row, model, index) {
if (model.data.EnableApprove == 'N') {
grid.getSelectionModel().deselect();
}
},
beforeselect: function (row, model, index) {
if (model.data.EnableApprove == 'N') {
MsgBox("Enable Approve !");
return false;
}
}
}
});
I tried to write it on afterrenderer, but it's not work.
I think you have to overrite selectAll (source) and deselectAll (source) methods of Ext.selection.CheckboxModelView.
Check this question and answer, I guess solution is somewhat you need.
I have a grid panel like:
Ext.define('Demo.view.main.content.source.Ex', {
extend: 'Ext.grid.Panel',
requires: [
'Demo.store.main.content.source.Ex',
'Demo.view.main.content.source.ExController',
],
xtype: 'app-main-content-ex',
title: 'Example',
store: 'Demo.store.main.content.source.Ex',
controller:'main-content-source-ex',
//multiSelect: false,
columnLines: true,
initComponent: function() {
var store = Ext.create('Demo.store.main.content.source.Ex', {
storeId: 'app-main-content-source-exstore'
});
Ext.apply(this, {
store: store
});
this.columns= [
{
text : 'Driver Name',
flex : 3,
sortable : false,
dataIndex: 'name'
},
{
xtype: 'gridcolumn',
getEditor: function(record) {
console.log(record.get('state'));
var value;
if (record.get('state') == 'free') {
value = 'xf09c#FontAwesome'
} else {
value = 'xf023#FontAwesome'
}
return Ext.create('Ext.grid.CellEditor', {
field:{
xtype: 'image',
glyph: value
}
});
},
text : 'State',
flex : 1,
dataIndex: 'state'
}]
this.callParent();
},
listeners:{
afterRender: 'setUpInfo'
}
});
I am loading the store of that in grid afterrender event. I want to set the image in the State column based on the value of state(free/busy). Its not working.
How should I do it?
You can use a renderer to augment the displayed value of the cell.
columns: [{
xtype: 'gridcolumn',
dataIndex: 'name',
text: 'Driver Name',
flex: 1,
editor: {
xtype: 'textfield'
}
}, {
xtype: 'gridcolumn',
renderer: function(value) {
if (value == 'free') {
return 'xf09c#FontAwesome'
} else {
return 'xf023#FontAwesome'
}
},
getEditor: function(record) {
var value;
if (record.get('state') == 'free') {
value = 'xf09c#FontAwesome'
} else {
value = 'xf023#FontAwesome'
}
return Ext.create('Ext.grid.CellEditor', {
field: {
xtype: 'image',
glyph: value
}
});
},
text: 'State',
flex: 1,
dataIndex: 'state'
}]
Docs: - http://docs.sencha.com/extjs/5.1/5.1.0-apidocs/#!/api/Ext.grid.column.Column-cfg-renderer
I am very new to extjs, and I saw this excellent post:
dynamic url inside a extjs table dont work
I was wondering if there is a way to enable checkbox functionality on the subtable?
I tried making slight modifications to the sample, but I can't find a way to have the checkboxes clickable and capture the events associated with it.
Please see the modified code below. Is it possible to have a clickable checkbox inside a Subtable?
Thanks in advance!
// SALVAGUARDAS -- added Approved field
Ext.define('Salvaguardas', {
extend: 'Ext.data.Model',
fields: ['Approved', 'id_amenaza', 'tipo', 'modo', 'codigo', 'denominacion', 'eficiencia', ]
});
//SALVAGUARDAS
var salvaguardaStore = Ext.create('Ext.data.Store', {
model: 'Salvaguardas',
data: [
{Approved: true, id_amenaza: 1, tipo: 'Correctiva', modo: 'Correctiva', codigo: 'corr-01', denominacion: 'correctiva 1', eficiencia: 'MB' }
]
});
//GRIDPANEL
Ext.create('Ext.grid.Panel', {
renderTo: 'example-grid',
store: amenazaStore,
//width: 748,
//height: 598,
title: '<bean:write name="informesAGRForm" property="nombreActivo"/>',
plugins: [{
ptype: "subtable",
headerWidth: 24,
listeners: {
'rowdblclick': function(grid, rowIndex, columnIndex, e){
// Get the Record, this is the point at which rowIndex references a
// record's index in the grid's store.
var record = grid.getStore().getAt(rowIndex);
// Get field name
var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
var data = record.get(fieldName);
alert(data);
}
},
columns: [{
//text: 'Approved',
//dataIndex: 'Approved',
//hidden: true,
//width: 100
xtype: 'checkcolumn',
header: 'Approved',
dataIndex: 'Approved',
width: 85,
listeners: {
checkChange: function ()
{
console.log('checkChange');
}
}
}, {
text: 'id_amenaza',
dataIndex: 'id_amenaza',
hidden: true,
width: 100
}, {
width: 100,
text: 'id_salvaguarda',
dataIndex: 'id_salvaguarda'
},
{
text: 'denominacion',
dataIndex: 'denominacion',
width: 100
},{
text: 'descripcion',
dataIndex: 'descripcion',
width: 100
},{
text: 'eficacia',
dataIndex: 'eficacia',
width: 100
},
],
getAssociatedRecords: function (record) {
var result = Ext.Array.filter(
salvaguardaStore.data.items,
function (r) {
return r.get('id_amenaza') == record.get('id');
});
return result;
}
}],
listeners: {
rowdblclick: function (view, record, tr, columnIndex, e) {
console.log('rowdblclick');
var cell = e.getTarget('.x-grid-subtable-cell');
if (!cell) {
return;
}
var row = Ext.get(cell).up('tr');
var tbody = row.up('tbody');
var rowIdx = tbody.query('tr', true).indexOf(row.dom);
//var records = view.up('grid').getPlugin('subtable').getAssociatedRecords(record);
var records = view.up('grid').plugins[0].getAssociatedRecords(record);
var subRecord = records[rowIdx];
console.log('rowdblclick: ' + rowIdx + ' - ' + subRecord);
},
rowclick: function (view, record, tr, columnIndex, e) {
console.log('rowclick');
var cell = e.getTarget('.x-grid-subtable-cell');
if (!cell) {
return;
}
var row = Ext.get(cell).up('tr');
var tbody = row.up('tbody');
var rowIdx = tbody.query('tr', true).indexOf(row.dom);
//var records = view.up('grid').getPlugin('subtable').getAssociatedRecords(record);
var records = view.up('grid').plugins[0].getAssociatedRecords(record);
var subRecord = records[rowIdx];
console.log('rowclick: ' + rowIdx + ' - ' + subRecord);
}
},
collapsible: false,
animCollapse: false,
columns: [
{
text: 'ID',
hidden: true,
hideable: false,
dataIndex: 'id'
},
{
text: 'Codigo',
width: 50,
sortable: true,
hideable: false,
dataIndex: 'codigo'
},
{
text: 'DenominaciĆ³n',
width: 150,
dataIndex: 'denominacion',
},
{
text: ' Autenticidad',
flex: 1,
dataIndex: 'a_riesgo'
},
{
text: 'Confidencialidad',
flex: 1,
dataIndex: 'c_riesgo'
},
{
text: 'Integridad',
flex: 1,
dataIndex: 'i_riesgo'
},
{
text: 'Disponibilidad',
flex: 1,
dataIndex: 'd_riesgo'
},
{
text: 'Trazabilidad',
flex: 1,
dataIndex: 't_riesgo'
},
{
text: 'Total',
flex: 1,
dataIndex: 'total_riesgo'
}]
});
i have a grid and scroll in a grid. this is my code for generate the grid
gridMain = Ext.create('Ext.grid.Panel', {
renderTo: Ext.get("sa-grid"),
store: 'pf-store',
height: mainContentHeight - 63,
title: 'Promotion Form',
columns: [{
text: 'No PF',
width: 115,
dataIndex: 'PFID'
},
{
text: 'Title',
flex: 1,
dataIndex: 'Title'
},
{
text: 'Promotion From',
dataIndex: 'PromotionFrom'
},
{
text: 'Promotion To',
dataIndex: 'PromotionTo'
},
{
text: 'Limit Payment Date',
width: 120,
dataIndex: 'LimitPaymentDate'
},
{
text: 'Request Status',
width: 150,
dataIndex: 'RequestDescription'
},
{
text: 'Initiator',
width: 150,
dataIndex: 'CreateByName'
}],
dockedItems: [{
xtype: 'toolbar',
items: [actAddPF, actEditPF, actDeletePF, actExtendPF]
}],
listeners: {
itemdblclick: function (view, record, item, index, e, eOpts) {
isGridClicked = true;
ViewDetails(FormState.VIEW);
}
}
});
function ViewDetails(FormState) {
var data = GetSelectedRecord(gridMain);
var id = data.PFID;
ShowLoading("sa-body", "Please Wait ...");
$.ajax({
type: 'POST',
url: root + "PF/GetDataByID",
data: { PFID: id },
success: function (result) {
try {
DataToArray(result);
DataToControl(result);
CreatePivotPeriode();
CreateMainPivot();
ChangeFormState(FormState);
tabs.setActiveTab('pageDetails');
} catch (err) {
MsgErr(err);
}
},
complete: function () {
try {
HideLoading();
} catch (err) {
MsgErr(err);
}
}
});
}
it works fine, but when i insert or modify data and load again or click search by parameter. the scroll is not working. the content in grid is update based on search parameter, the problem is only the scroll which is not working anymore. then I have to do F5 to refresh it again so the grid can be scroll again.
this is my code for searching in grid
$("#btnSearch").click(function () {
ShowLoading("sa-body", "Please Wait ...");
$.post(root + "PF/Search", { FieldName: $("#cbSearch").val(), Pattern: $("#cbPattern").val(), Condition: $("#txtSearch").val() }, function (data) {
storePF.loadDataViaReader(data);
HideLoading();
});
});
Does someone have a solution about this problem ?
Many thanks
i can do by this
:)
Ext.override(Ext.grid.Scroller, {
onAdded: function() {
this.callParent(arguments);
var me = this;
if (me.scrollEl) {
me.mun(me.scrollEl, 'scroll', me.onElScroll, me);
me.mon(me.scrollEl, 'scroll', me.onElScroll, me);
}
}
});
I am new to ExtJs, and i am playing around to build logic to perform "live search" on Grid columns.
From the code below i am able to populate data into the grid but cannot make live search functionality. i am not sure where i am missing the logic.
Ext.define('abc.view.EmployeePanel', {
extend: 'Ext.window.Window',
alias: 'widget.EmployeePanel',
requires: [
'Ext.tab.Panel',
'Ext.form.*'],
constructor: function () {
this.callParent(arguments);
},
this. employeePopUPGridStore = new Ext.data.ArrayStore({
fields: [
{
name: 'empid',
type: 'number'
},
{
name: 'fname',
type: 'string'
},
{
name: 'lname',
type: 'string'
},
],
});
this.employeePopUPGridStore.loadData(localAr, false);
this.down('#addempgrid').bindStore(this.employeePopUPGridStore);
this.down('#addempgrid').getView().refresh();
},
items: [{
xtype:'textfield',
name:'search',
itemId:'search',
emptyText:'Search by First Name / Last Name',
listeners: {
onTextFieldChange: function(field, newValue, oldValue, eOpts){
var grid = field.down('addempgrid');
grid.store.clearFilter();
if (newValue) {
var matcher = new RegExp(Ext.String.escapeRegex(newValue), "i");
grid.store.filter({
filterFn: function(item) {
return matcher.test(item.get('empid')) ||
matcher.test(item.get('fname')) ||
matcher.test(item.get('job'));
}
});
}
}
}
},
{
xtype: 'gridpanel',
itemId: 'addempgrid',
autoHeight: true,
columns: [
{
header: "Employee ID",
flex: 1,
dataIndex: 'empid',
},
{
header: "Full Name",
flex: 3,
dataIndex: 'fname'
},
{
header: "LastName",
flex: 1,
dataIndex: 'lname'
},
]
}
] }
});
Any help around is much appreciated.
Hi Please try this way once..
{
xtype: 'textfield',
itemId: 'searchBar',
cls: 'search-bar',
width: 230,
margin: '0 0 0 10',
listeners: {
buffer: 250,
scope: this,
change: function (field, newVal) {
var grid = field.down('addempgrid');
grid.store.clearFilter();
if (newValue) {
var matcher = new RegExp(Ext.String.escapeRegex(newValue), "i");
grid.store.filter({
filterFn: function(item) {
return matcher.test(item.get('empid')) ||
matcher.test(item.get('fname')) ||
matcher.test(item.get('job'));
}
});
}
}
}
}
Hope it helps you