Date format in a textfield - date

I have a textfield:
xtype: "fieldset",
items:[
{
xtype: "textfield",
name: "dateScanned",
label: "Datum",
disabled: true,
tpl: "{dateScanned:date('d/m/Y H:i')}" // <--- this dosn't work
}
]
My Store is:
fields: [
{ name: 'dateScanned', type: 'date', dateFormat: 'c' }
]
Why does the marked point not work?
How can I realize that the date is fomatted?

/*Override to allow textfields to format dates*/
Ext.override(Ext.field.Text, {
setValue: function (value) {
if (this.config.dateFormat && value) {
if (Ext.isDate(value)) {
value = Ext.Date.format(value, this.config.dateFormat);
}
else {
var d = new Date(value);
value = Ext.Date.format(d, this.config.dateFormat);
}
}
this.callSuper(arguments);
}
});

MyAppWhere do you insert that override up there?
If i add a new Text.js under app/field/Text.js and link it under require it doesn't work
SOLUTION
/*Override to allow textfields to format dates*/
Ext.define('MyApp.field.Text', {
override: 'Ext.field.Text',
setValue: function (value) {
if (this.config.dateFormat && value) {
if (Ext.isDate(value)) {
value = Ext.Date.format(value, this.config.dateFormat);
}
else {
var d = new Date(value);
value = Ext.Date.format(d, this.config.dateFormat);
}
}
this.callSuper(arguments);
}
});
You create a folder in your project Project/app/field/Text.js and put the code in
And then under requires add
requires: [
'MyApp.field.Text'
],

I have a solution:
dateFormat instead of tpl
xtype: "fieldset",
items:[
{
xtype: "datepickerfield",
name: "dateScanned",
label: "Datum",
disabled: true,
dateFormat: "d.m.Y H:i"
//tpl: "{dateScanned:date('d/m/Y H:i')}" // <--- this dosn't work
}
]
I don't know, but I believe to remember that it is important to set the double question marks.

Related

Toggle Select All not working for grid.js

I have a grid js defined as follows. I have select all check box on which I want to select/deselect all the rows. I am able to perform select all but deselect all does not work. Can anyone please help. Thanks.
const grid = new gridjs.Grid({
columns: [
{
id: "selectId", name: "Select",
plugin: {
component: gridjs.plugins.selection.RowSelection,
props: {id: (row) => row.cell(1).data}
}
},
{ id: "columnName", name: "Column Name" },
{ id: "dataType", name: "Data Type"}
],
data: [],
});
function init(){
grid.render("#data-grid);
}
function loadGrid(){
$.get("/someURL",function(response) {
if(response.success){
fileSchemaGrid.updateConfig({
data: response.data
}).forceRender();
}
});
}
function toggle(){
if($("#checkbox-select-all-rows").is(":checked")){
//This block works
fileSchemaGrid.config.columns[0].data = true;
fileSchemaGrid.forceRender();
}else{
//*** This block does not work***
fileSchemaGrid.config.columns[0].data = false
fileSchemaGrid.forceRender();
}
}
I had the same issue and found that this works - but its a bit hacky.
function toggle(){
if($("#checkbox-select-all-rows").is(":checked")){
//This block works
fileSchemaGrid.config.columns[0].data = true;
fileSchemaGrid.forceRender();
}else{
//*** This block should now work***
fileSchemaGrid.config.columns[0].data = null;
fileSchemaGrid.config.plugin.get('selectId').props.store.state.rowIds = [];
fileSchemaGrid.forceRender();
}
}

Rendering a menu in vue 3 after ajax method

I've gotten this menu to work without filtering it, but now I'm doing an ajax request to filter out menu items the user isn't supposed to see, and I'm having some trouble to figure out how to set the resulting menu data, the line that is not working is commented below:
<script>
import { ref } from 'vue';
import axios from 'axios';
var currentSelected = 'device_access';
var menuData = [
{
text: 'Device Access',
id: 'device_access',
children: [
{
text: 'Interactive',
link: '/connection_center'
},{
text: 'Reservation',
link: '/reserve_probe'
}, {
text: 'Reservation Vue',
link: '/reservation.html'
}
]
}, {
text: 'Automation',
id: 'automation',
show: ['is_mxadmin', 'can_schedule_scripts'],
children: [
{
text: 'Builder',
link: '/builder',
},{
text: 'Execution Results',
link: '/test_suite_execution_results'
},
]
}
];
function hasMatch(props, list) {
var match = false;
for (var i=0; i < list.length && !match; i++) {
match = props[list[i]];
}
return match;
}
export default {
name: 'Header',
setup() {
const cursorPosition = ref('0px');
const cursorWidth = ref('0px');
const cursorVisible = ref('visible');
//the menu is zero length until I get the data:
const menu = ref([]);
return {
menu,
cursorPosition,
cursorWidth,
cursorVisible
}
},
created() {
let that = this;
axios.get('navigation_props')
.then(function(res) {
var data = res.data;
var result = [];
menuData.forEach(function(item) {
if (!item.show || hasMatch(data, item.show)) {
var children = [];
item.children.forEach(function (child) {
if (!child.show || hasMatch(data, child.show)) {
children.push({ text: child.text, link: child.link });
}
});
if (children.length > 0) {
result.push({ text: item.text,
children: children, lengthClass: "length_" + children.length });
}
}
});
//continues after comment
this is probably the only thing wrong, I've run this in the debugger and I'm getting the
correct data:
that.$refs.menu = result;
since the menu is not being rebuilt, then this fails:
//this.restoreCursor();
})
.catch(error => {
console.log(error)
// Manage errors if found any
});
},
this.$refs is for template refs, which are not the same as the refs from setup().
And the data fetching in created() should probably be moved to onMounted() in setup(), where the axios.get() callback sets menu.value with the results:
import { onMounted, ref } from 'vue'
export default {
setup() {
const menu = ref([])
onMounted(() => {
axios.get(/*...*/).then(res => {
const results = /* massage res.data */
menu.value = results
})
})
return {
menu
}
}
}
I finally figured out the problem.
This code above will probably work with:
that.menu = result;
You don't need: that.$refs.menu
You can't do it in setup because for some reason "that" is not yet defined.
In my working code I added a new method:
methods: {
setMenuData: function() {
this.menu = filterMenu();
},
}
And "this" is properly defined inside them.

Autoform meteor dependable/cascading selects

how can I implement 3 dependent selects with autoform in meteor?
Here is an example of what I need to achieve http://www.ajaxray.com/Examples/depend.html
Thanks in advance for any help
You could add an event listener to your select and when it changes, update the select helper for the next select (or all select's) you have in your form. It would be something similar to the following example, but update the "options" object depending on what was selected by a different select input.
http://autoform.meteor.com/select
This is the way I solved it. However for the third select to return the selected value once the first select is updated I had to use JQuery. This might help to someone in need of something similar. But if there is a better way to do it please let me know.
Organizaciones = new Mongo.Collection('organizaciones');
Organizaciones.attachSchema(new SimpleSchema({
provincia: {
type: String,
label: 'Provincia',
autoform: {
type: 'select',
firstOption: '',
options: function () {
return DPA.find({grupo: 'Provincia'}).map(function (dpa) {
return {label: dpa.descripcion, value: dpa.codigo};
});
}
}
},
canton: {
type: String,
label: 'Cantón',
autoform: {
type: 'select',
firstOption: '',
options: function () {
var codigoProvincia = AutoForm.getFieldValue('provincia');
var cantones = new RegExp('^' + codigoProvincia + '[\d]{2}$');
return DPA.find({codigo: {$regex: cantones}}).map(function (dpa) {
return {label: dpa.descripcion, value: dpa.codigo};
});
}
}
},
parroquia: {
type: String,
label: 'Parroquia',
autoform: {
type: 'select',
firstOption: '',
options: function () {
$('#provincia').change(function() {
$('#parroquia option[value!=""]').remove();
});
var codigoCanton = AutoForm.getFieldValue('canton');
var parroquias = new RegExp('^' + codigoCanton + '[\d]{2}$');
return DPA.find({codigo: {$regex: parroquias}}).map(function (dpa) {
return {label: dpa.descripcion, value: dpa.codigo};
});
}
}
}
}));

How to cancel wrapping of text in ExtJs Combobox List?

This my code:
function sim(proxy, data, delay) {
if (typeof data !== 'string') {
data = Ext.JSON.encode(data);
}
proxy.url = '/echo/json/';
proxy.actionMethods.read = "POST";
proxy.extraParams.json = data;
proxy.extraParams.delay = typeof delay == 'undefined' ? 0 : delay;
}
Ext.define('MyStore', {
extend:'Ext.data.Store',
fields:['id','name'],
proxy:{
url:'whatever',
type:'ajax',
reader:{
type:'json'
}
}
});
var myStore = new MyStore();
sim(myStore.proxy, [{id:2,name:'neil'},{id:3,name:'expert wanna-be expert wanna expert'}], 0);
Ext.define('MyForm', {
extend: 'Ext.form.Panel',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'combobox',
editable:false,
store: myStore,
valueField: 'id',
displayField:'name',
}
]
});
me.callParent(arguments);
}
});
var myForm = new MyForm({renderTo:Ext.getBody()});
I don't want to increase the width of the column. I want to increase width of the combobox list respective of the text size in store inorder to cancel the wrapping of text.
Help me. Thanks in advance.
If I correctly understand your problem you can try matchFieldWidth: false config:
{
xtype: 'combobox',
editable:false,
store: myStore,
valueField: 'id',
displayField:'name',
matchFieldWidth: false
}
For additional configurations of dropdown use listConfig option.

how to save an entire object in a variable on a kendo autocomplete selection

i need help about a kendo autocomplete widget...
Maybe this is a stupid question, but i just can't reach the solution!!!
My kendoAutoComplete widget, gets data from a c# webservice:
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
[WebMethod]
public string getComuniList()
{
using (PrintInvoicesDataContext context = new PrintInvoicesDataContext())
{
List<comuni_italia> comuni = new List<comuni_italia>();
comuni = context.comuni_italia.ToList();
var jsonStr = JsonConvert.SerializeObject(comuni, Formatting.Indented);
return jsonStr;
}
}
this method returns a long object array like this:
[ {id_comune: 1, des_comune: "Milano", cod_comune: "A130", cap_comune: "64022"},
{id_comune: 2, des_comune: "Torino", cod_comune: "A131", cap_comune: "64100"},
....
]
so, when i choose an item into the kendo autocomplete widget, on the select event, i need to save the whole selected object in a variable.
var comuneAutoComplete = $("#comune_w").kendoAutoComplete({
minLength: 3,
dataSource: dataSource,
placeholder: "Inserisci comune...",
dataTextField: "des_comune",
dataValueField: "id_comune"
}).data("kendoAutoComplete").bind("select", function (data) {
//here i want to save the object
var comune = ????????
});
so that i could get fields values like this:
var id_com = comune.id_comune;
var des_com = comune.des_comune;
..........
this is the model of the datasource:
model: {
fields: {
id: "id_comune",
id_comune: { type: "string" },
des_com: { type: "string" },
des_prv: { type: "string" },
des_reg: { type: "string" },
cod_com: { type: "string" },
cod_prv: { type: "string" },
cod_res: { type: "string" }
}
Is it possible??
hope someone can help me!
thanks in advance.
Getting the data from the dataSource for the selected item is:
var comuneAutoComplete = $("#comune_w").kendoAutoComplete({
minLength: 3,
dataSource: dataSource,
placeholder: "Inserisci comune...",
dataTextField: "des_comune",
dataValueField: "id_comune"
}).data("kendoAutoComplete").bind("select", function (data) {
//here i want to save the object
var comune = this.dataItem(e.item.index());
...
});