I have a comment text area in an editor in the grid, but if i write some text and then i push the enter it just complete edit and not create new line. What i want is if i hit enter key, its create new line like this:
Example :
" Wrong list:
asdasdasd
asdasdasdas"
Now i just write in comment like this : "Wrong list: 1.asdasd 2.asdasdasd"
What i must to do with my js?
This is the grid i have:
This is the code :
var chat_grid = Ext.create('Ext.grid.Panel', {
id: 'chatGrid',
store: SuratPesananChatDetailStore,
height: 350,
title: 'Comment Grid',
viewConfig: {
emptyText: '<P ALIGN="CENTER"><font color="red"><U> Tidak ada data </U></font></P>',
getRowClass: function (record, rowIndex, rp, store) {
return 'rowgridspdetailnonstd-height';
}
},
plugins: Ext.create('Ext.grid.plugin.RowEditing', { clicksToEdit: 2, pluginId: 'rowEditingID' }),
frame: true,
loadMask: true,
stripeRows: true,
autoScroll: true,
selModel: GridChatSelectionModel,
cls: 'rowgridspdetailnonstd-height',
tbar:
[
{
id: "IdAddCommentLookUp",
text: "Add Comment",
iconCls: "icon-grid-add",
listeners:
{
'click': function () {
AddCommentListener();
}
}
},
{
id: "IdDeleteChat",
text: "Delete Comment",
iconCls: "icon-cancel",
disabled: true,
listeners:
{
'click': function () {
DeleteChatListener();
}
}
},
{
id: "IdInviteUser",
text: "Invite User",
iconCls: "icon-grid-add",
hidden: true,
listeners:
{
'click': function () {
InviteUserLookUp();
}
}
}
],
columns:
[
{
header: 'Date',
dataIndex: 'CreatedOn',
width: 120,
hidden: false,
sortable: false,
sortableColumn: false
},
{
header: 'Comment',
dataIndex: 'Comment',
editor: { xtype: 'textareafield', allowblank: false, maxLength: 165, enforceMaxLength: true, height: 100, grow: true, completeOnEnter: false },
hidden: false,
width: 370,
sortable: false,
sortableColumn: false
},
{
header: 'Created By',
dataIndex: 'CreatedBy',
width: 120,
hidden: false,
sortable: false,
sortableColumn: false
},
{
header: 'Department',
dataIndex: 'Department',
width: 120,
hidden: false,
sortable: false,
sortableColumn: false
},
{
header: 'Document Name',
dataIndex: 'FileName',
width: 150,
hidden: false,
sortable: false,
sortableColumn: false
},
{
header: 'Upload Document',
dataIndex: 'Panel',
width: 120,
hidden: false,
sortable: false,
sortableColumn: false,
renderer: function (v, m, r, row) {
if (r.data.Panel == 'Download') {
var fileName = r.data.FilePath;
return "" + v + "";
}
else if (r.data.Panel == 'Upload') {
return "" + v + "";
}
else {
return v;
}
}
}
]
});
I have try all the way in google but i can't solve this case.
Enable keyevents of your comment editor, and stopEvent() in Enter key
Sample config:
editor: {
xtype: 'textareafield',
allowblank: false,
maxLength: 165,
enforceMaxLength: true,
height: 100,
grow: true,
completeOnEnter: false,
enableKeyEvents: true, //Listen to keyevents
listeners: {
keydown: function(field, e) {
if (e.getKey() == e.ENTER) {
e.stopEvent(); // Stop event propagation
}
}
}
}
Ref: https://www.sencha.com/forum/showthread.php?293592-Stop-RowEditing-plugin-from-completing-the-edit-on-keypress-enter
Related
does anybody know how to set the checkbox in a RowEditor into the center position?
I use the theme "triton" with Ext JS 6.0.0.
The checkbox is placed to the top of the row, but the other fields like textfield or combobox are placed to center.
It looks like:
i already set the style object of the checkbox to align: center but it didn't work.
plugins: { ptype: 'rowediting', clicksToEdit: 2, saveBtnText: 'Übernehmen', cancelBtnText: 'Abbrechen' },
initComponent: function() {
var me = this;
me.store = 'MeasurementPoint';
me.columns = [
{
xtype: 'actioncolumn',
width: 50,
sortable: false,
hideable: false,
resizable: false,
menuDisabled: true,
draggable: false,
items: [
{
icon: 'Content/images/icon_32/garbage.png',
tooltip: 'Löscht den Eintrag',
handler: function(view, rowIdx, colIdx, item, ev, record) {
Ext.Msg.show({
title: 'Löschen bestätigen!',
msg: 'Soll der Messpunkt \"' + record.data.Name + '\" wirklich gelöscht werden?',
width: 300,
buttons: Ext.Msg.YESNO,
fn: function(btn) { if (btn === 'yes') view.ownerCt.getStore().remove(record); },
//animateTarget: rowIdx,
icon: Ext.window.MessageBox.QUESTION
});
}
},
{
icon: 'Content/images/icon_32/pencil.png',
tooltip: 'Bearbeitet den Eintrag',
handler: function(view, rowIdx, colIdx, item, ev, record) {
if (this.__form)
return;
this.__form = Ext.widget('window', {
layout: 'fit',
width: 500,
title: 'Messpunkt bearbeiten',
items: { xtype: 'measurementpointform', header: false },
}).show();
this.__form.down('button[itemId=save-measurementpoint]').action = 'update-measurementpoint';
this.__form.down('form').loadRecord(record);
this.__form.on('close', function() { this.__form = false }, this, { single: true });
}
}
]
},
{
xtype: 'gridcolumn',
dataIndex: 'Active',
text: 'Aktiv',
width: 70,
renderer: AWA.ImageRenderer.CROSS,
editor: {
xtype: 'checkbox',
}
},
{
xtype: 'gridcolumn',
dataIndex: 'Manually',
text: 'Manuell',
width: 90,
renderer: AWA.ImageRenderer.TICK,
editor: {xtype: 'checkbox'}
}
Thank you guys for helpful anwers
I have overwritten the CSS and it works for me
.x-grid-editor .x-form-cb-wrap {
vertical-align: middle;
}
Thanks
I'm trying to put a GridPanel powered by an ArrayStore in a Window, but no matter what I do, it just looks like this with no data rows inside:
Here's my code:
var ticketsStore = new Ext.data.ArrayStore
(
{
autoDestroy: false,
remoteSort: false,
data: result,
fields:
[
{ name: 'articleId', type: 'int' },
{ name: 'heatTicketRef', type: 'string' },
{ name: 'username', type: 'string' },
{ name: 'dateLinked', type: 'date' }
]
}
);
var ticketsGrid = new Ext.grid.GridPanel({
store: ticketsStore,
id: this.id + 'ticketsGrid',
viewConfig: {
emptyText: 'No data'
},
autoShow: true,
idProperty: 'heatTicketRef',
columns: [
{ id: 'heatTicketRef', header:"Ticket ID", width: 100, dataIndex: 'heatTicketRef', sortable: false },
{ header: "User", width: 100, dataIndex: 'username', sortable: false },
{ header: "Date Linked", width: 100, dataIndex: 'dateLinked', xtype: 'datecolumn', format: 'j M Y h:ia', sortable: false }
]
});
var window = new Ext.Window
(
{
renderTo: Ext.getBody(),
id: this.id + 'linkedHeatTickets',
closable: true,
modal: true,
autoHeight: true,
width: 500,
title:'Linked Heat Tickets',
resizable: false,
listeners:
{
close: function () { // do something }
},
items:
{
style: 'padding:5px;',
items: ticketsGrid
},
buttons:
{
text: 'Close',
handler: function () {
window.close();
}
}
}
);
window.show();
When I debug, I can see that my "result" object is healthy and the ArrayStore is of the right length:
But the GridPanel doesn't like the data because it's not in its items (although it's in the store) array:
What little thing have I done wrong?
Thanks!
Because I'm an idiot... I used an ArrayStore instead of a JsonStore!
I am trying to add one paging toolbar in my existing toolbar and hide the first, previous, next, last and refresh button by using following code. My problem is that I am unable to fetch correct afterPageText value(total number of pages). I m doing this for resultlist in xCP Designer. Plz help.
CODE:
Ext.define('Override.toolbar.Paging', {
override: 'Ext.toolbar.Paging',
hideFirstButton: false,
hidePrevButton: false,
hideBeforePageText: false,
hidePageNumberField: false,
hideAfterPageText: false,
hideNextButton: false,
hideLastButton: false,
hideRefreshButton: false,
getPagingItems: function() {
var me = this;
return [{
itemId: 'first',
tooltip: me.firstText,
overflowText: me.firstText,
iconCls: Ext.baseCSSPrefix + 'tbar-page-first',
hidden: me.hideFirstButton,
disabled: true,
handler: me.moveFirst,
scope: me
}, {
itemId: 'prev',
tooltip: me.prevText,
overflowText: me.prevText,
iconCls: Ext.baseCSSPrefix + 'tbar-page-prev',
hidden: me.hidePrevButton,
disabled: true,
handler: me.movePrevious,
scope: me
}, {
xtype: 'tbseparator',
hidden: me.hideFirstButton && me.hidePrevButton
}, {
xtype: 'tbtext',
text: me.beforePageText,
hidden: me.hideBeforePageText
}, {
xtype: 'numberfield',
itemId: 'inputItem',
name: 'inputItem',
hidden: me.hidePageNumberField,
cls: Ext.baseCSSPrefix + 'tbar-page-number',
allowDecimals: false,
minValue: 1,
hideTrigger: true,
enableKeyEvents: true,
keyNavEnabled: false,
selectOnFocus: true,
submitValue: false,
isFormField: false,
width: me.inputItemWidth,
margins: '-1 2 3 2',
listeners: {
scope: me,
keydown: me.onPagingKeyDown,
blur: me.onPagingBlur
}
}, {
xtype: 'tbtext',
itemId: 'afterTextItem',
hidden: me.hideAfterPageText,
text: "of {0}"
}, {
xtype: 'tbseparator',
hidden: me.hideNextButton && me.hideLastButton
}, {
itemId: 'next',
tooltip: me.nextText,
overflowText: me.nextText,
iconCls: Ext.baseCSSPrefix + 'tbar-page-next',
hidden: me.hideNextButton,
disabled: true,
handler: me.moveNext,
scope: me
}, {
itemId: 'last',
tooltip: me.lastText,
overflowText: me.lastText,
iconCls: Ext.baseCSSPrefix + 'tbar-page-last',
hidden: me.hideLastButton,
disabled: true,
handler: me.moveLast,
scope: me
}, {
xtype: 'tbseparator',
hidden: me.hideRefreshButton
}, {
itemId: 'refresh',
hidden: me.hideRefreshButton,
tooltip: me.refreshText,
overflowText: me.refreshText,
iconCls: Ext.baseCSSPrefix + 'tbar-loading',
handler: me.doRefresh,
scope: me
}];
}
});
xcp.widget.grid.ResultsListGrid.override({
initComponent: function () {
var me = this;
this.dockedItems = [
{
xtype: 'toolbar',
//store: me.store,
dock: 'bottom',
height: '45px',
items: [
//'->',//right alight the button
{
xtype: 'xcp_pagingtoolbar',
store: me.store,
//flex: true,
dock: 'bottom',
displayInfo: true
},'->',
{
xtype: 'pagingtoolbar',
store: me.store,
displayInfo: false,
hideRefreshButton: true,
hideFirstButton: true,
hideLastButton: true,
hidePrevButton: true,
hideNextButton: true,
//disabled: true
}
]
},
];
this.callParent();
}
}
);
Thanks.
-SS
Incorrect total number of pages, or any discrepancy in paging info, are almost always caused by an incorrect server response.
If we have configured pageSize:20 and we want page 2, server must return exactly 20 records, starting from record 21 (1 based numbering) and must return correct total number of records in the table.
i want to Bind a kendogrid, with large datasource (json array), that includes the display of detail temeplates too in 3-4 tabs. But it doesn't display the grid. (for 1500 rows) Could there be anything dynamic to display page by page? No search criteria required for solution.
Please advise.
Thanks Yogesh
function bindgridsimple()
{
var element = $("#grid").kendoGrid({
dataSource: {
transport: {
read: url
},
pageSize: 25
},
columnMenu: true,
scrollable: true,
filterable: true,
resizable: true,
sortable: true,
detailTemplate: kendo.template($("#template").html()),
detailInit: detailInit,
dataBound: function () {
},
columns: [
{
field: "FirstName",
width: "8%",
title: "Candidate Name",
template: "<a href='Candidates/candidaterequirementmapping.aspx?CandId=#=CandidateId#'> <span>#=FirstName#</span> <span>#=LastName#</span></a>"
},
{
field: "Mobile",
width: "8%",
title: "Mobile"
},
{
field: "ResumeTitle",
width: "10%",
title: "Resume Title"
},
{
field: "CreatedByUser",
width: "10%",
title: "Created by"
},
{
field: "ExpectedSalary",
width: "15%",
title: "Expected Salary",
template: "<span># if(ExpectedSalary == null) { # 0.00 # } else { #<span>#=ExpectedSalary#</span># }#</span> / <span>#=ExpectedSalaryperiod#</span>"
}, {
field: "MarketingRate",
width: "10%",
title: "Mktg Rate",
template: "<span># if(MarketingRate == null) { # 0.00 # } else { #<span>#=MarketingRate#</span># }#</span> / <span>#=MarketingRateperiod#</span>"
},
{
field: "CreatedDate",
width: "15%",
title: "Resume Received Date",
template: '#if(Resume == null || Resume == "") { } else { # <span> #=parseFullDate(CreatedDate)# </span> # } #'
},
{
field: "ExistMappedCandidate",
width: "10%",
title: "Req. Provided"
},
{
field: "ExistMappedCandidate",
width: "10%",
title: "View",
template: "# if(ExistMappedCandidate==true){ #<a href='Candidates/candidaterequirementmapping.aspx?CandId=#=CandidateId#'>View Requirement</a> #} else {# <a href='Candidates/candidaterequirementmapping.aspx?CandId=#=CandidateId#' class='No-candidates' onclick='return false' title='No requirements are mapped with this candidate.'>View Requirement</a> #}#"
}
],
pageable: {
pageSizes: [25, 50, 75]
}
});
}
function detailInit(e) {
var sharableDataSource = new kendo.data.DataSource({ data: e.data.Experience });
var sharableDataSourceAttachment = new kendo.data.DataSource({ data: e.data.Attachments });
var detailRow = e.detailRow;
detailRow.find(".tabstrip").kendoTabStrip({
animation: {
open: { effects: "fadeIn" }
}
});
detailRow.find(".prevExperience").kendoGrid({
dataSource: { data: e.data.Experience,
pageSize: 10
},
columnMenu: true,
scrollable: true,
filterable: true,
resizable: false,
sortable: true,
pageable: {
pageSizes: [10, 20]
},
columns: [
{ field: "Company", title: "Company Name", width: "100px" },
{ field: "Designation", title: "Designation", width: "100px" },
{ field: "FromDate", title: "From", width: "100px", template: '#=parsemyDate(FromDate)#' },
{ field: "ToDate", title: "To", width: "100px", template: '#=parsemyDate(ToDate)#' },
{ field: "LastSalary", title: "Last CTC", width: "65px", template: '#=LastSalary# / Yr' }
]
});
detailRow.find(".attachments").kendoGrid({
//dataSource: sharableDataSourceAttachment,
dataSource: { data: e.data.Attachments,
pageSize: 10
},
columnMenu:true,
scrollable: false,
sortable: true,
filterable: true,
pageable: {
pageSizes: [10, 20]
},
columns: [
{ field: "AttachmentName", sortable: true, filterable: true, title: "File Icon", width: "100px", template: '#= AttachmentTitle #'
},
// { field: "AttachmentTitle", title: "Type", width: "100px" },
// { field: "AttachmentName", title: "Subject", width: "100px", template: 'Resume' },
{field: "CreatedbyUser", sortable: true, filterable: true, title: "Attached By", width: "100px" },
{ field: "Createddate", title: "Date", sortable: true, filterable: true, width: "65px", template: '#=parseFullDate(Createddate)#' }
]
});
}
I have an Editor Grid and a store with a custom type in it.
store :
var sourceStore = new Ext.data.JsonStore({
url: hp,
storeId: 'labels-data-store',
idProperty: 'ID',
root: 'results',
fields: [{
name: 'ID',
type: 'int'
}, {
name: 'LanguageID',
type: 'int'
}, {
name: 'KeyID',
type: 'int'
}, {
name: 'Value',
type: 'string'
}, {
name: 'ToolTip',
type: 'string'
}, {
name: 'LanguageName',
type: 'string'
}, {
name: 'KeyInfo',
type: 'LanguageKeyInfo'
},
CUSTOM TYPE HERE !! !{
name: 'ServerComments',
type: 'string'
}]
});
Editor Grid :
var sourceGrid = new Ext.grid.EditorGridPanel({
id: 'source-grid',
region: 'center',
title: localize.sourceView,
iconCls: 'source-view-title',
store: sourceStore,
trackMouseOver: true,
disableSelection: false,
loadMask: true,
split: true,
stripeRows: true,
border: true,
autoExpandColumn: 'label',
cm: sourceColModel,
// customize view config
viewConfig: {
forceFit: true,
enableRowBody: true,
showPreview: false,
emptyText: localize.noRecordsFound
},
sm: new Ext.grid.RowSelectionModel({
singleSelect: false,
moveEditorOnEnter: true
})
});
Custome Type implementation:
LanguageKeyInfo = function () {
this.ID = arguments[0];
this.Value = arguments[1];
this.Description = arguments[2];
}
Ext.data.Types.LANGUAGEKEYINFO = {
convert: function (v, data) {
if (!data) {
return null;
}
if (!data.KeyInfo) {
return null;
}
return new LanguageKeyInfo(
data.KeyInfo.ID,
data.KeyInfo.Value,
data.KeyInfo.Description);
},
sortType: function (key) {
return key.ID;
},
type: 'LanguageKeyInfo'
}
Source Column Model:
var sourceColModel = new Ext.grid.ColumnModel({
columns: [{
header: 'ID',
dataIndex: 'ID',
width: 50,
hidden: true,
sortable: true
}, {
header: 'Language ID',
dataIndex: 'LanguageID',
width: 50,
hidden: true,
sortable: true
}, {
header: 'Language',
dataIndex: 'LanguageName',
width: 20,
hidden: true,
sortable: true
}, {
header: 'Key ID',
dataIndex: 'KeyID',
width: 30,
hidden: true,
sortable: true
}, {
header: 'Key',
dataIndex: 'KeyValue',
width: 40,
sortable: true,
editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 200
})
}, {
header: 'Label',
dataIndex: 'Value',
sortable: true,
editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 500
}),
renderer: function (sc) {
var lanID = getSelectedLanguageID() ? getSelectedLanguageID() : 1;
switch (parseInt(lanID)) {
case 2:
return '<div class="rtl">' + sc + '</div>';
default:
return sc;
}
}
}, {
header: 'Description',
dataIndex: 'KeyDescription',
width: 30,
editor: new Ext.form.TextField({
allowBlank: true,
vtype: 'englishOnly',
maxLength: 100
})
}, {
header: 'Tool Tip',
dataIndex: 'ToolTip',
width: 80,
sortable: true,
editor: new Ext.form.TextField({
allowBlank: true,
maxLength: 200
})
}]
});
When I start editing the first column row the text field value is [object,object] which mean the grid is passing the KeyInfo object to the textbox value.
How can I send one of KeyInfo properties to the textbox and have it mapped to the store record ??
For starters your dataIndex does not reference a valid record mapping:
dataIndex: 'KeyValue', should probably be dataIndex: 'KeyInfo',
Secondly I don't think there is any support for custom types on grid editors. I might be wrong of course.