Please see below for the example. Console logs an array with "undefined" objects when checking the items from the dropdown. What is the correct way to get an array of checked items?
http://jsfiddle.net/4L3sksmt/4/
require(['dojox/form/CheckedMultiSelect'],function(CheckedMultiSelect){
var groupCheckedMultiSelect = new CheckedMultiSelect ({
id: "groupChkMultiSelect",
dropDown: true,
multiple: true,
label: "Group",
onChange: function(evt){
console.log(evt);//output = undefined
}
}, 'GroupDiv');
groupCheckedMultiSelect.addOption({'label':'One'});
groupCheckedMultiSelect.addOption({'label':'Two'});
groupCheckedMultiSelect.addOption({'label':'Three'});
groupCheckedMultiSelect.addOption({'label':'Four'});
groupCheckedMultiSelect.addOption({'label':'Five'});
groupCheckedMultiSelect.startup();
});
The undefined values are returned because you are not setting the value for the options. The correct format for options are { label : 'One', value: 1 }. Below code should be working now.
require(['dojox/form/CheckedMultiSelect'],function(CheckedMultiSelect){
var groupCheckedMultiSelect = new CheckedMultiSelect ({
id: "groupChkMultiSelect",
dropDown: true,
multiple: true,
label: "Group",
onChange: function(evt){
console.log(evt);//output = undefined
}
}, 'GroupDiv');
groupCheckedMultiSelect.addOption({'label':'One', value: 1});
groupCheckedMultiSelect.addOption({'label':'Two', value: 2});
groupCheckedMultiSelect.addOption({'label':'Three', value: 3});
groupCheckedMultiSelect.addOption({'label':'Four', value: 4});
groupCheckedMultiSelect.addOption({'label':'Five', value: 5});
groupCheckedMultiSelect.startup();
});
Related
I have Datatable with statesave and header filter, see below code.
dttblEnrolledUser = $('#tblUsers').dataTable({
paging: true,
searching: true,
bLengthChange: false,
info: false,
ordering: true,
columnDefs:
[{ targets: 0, orderable: false },
{ targets: 5, orderable: false }],
order: [1, 'asc'],
stateSave: true,
dom: '<"top"i>rt<"bottom"flp><"clear">'
});
here is the code for Statesave and applying filtered value.
var state = dttblEnrolledUser.api().state.loaded();
if (state) {
dttblEnrolledUser.api().columns().eq(0).each(function (colIdx)
{
var colSearch = state.columns[colIdx].search;
if (colSearch.search) {
$( 'input', dttblEnrolledUser.api().column( colIdx ).header() ).val( colSearch.search );
}
});
dttblEnrolledUser.api().draw();
}
// Apply the search
dttblEnrolledUser.api().columns().eq(0).each( function (colIdx) {
$('input', dttblEnrolledUser.api().column(colIdx).header()).on( 'keyup change', function () {
dttblEnrolledUser.api()
.column( colIdx )
.search( this.value )
.draw();
});
});
What I Want?
My main priority is to remove sorting from statesave, I mean if user refresh page, sorting should be on default column.
but at that time filter should be work with statesave.
What I did?
I tried to add code like this.
https://datatables.net/reference/api/state.clear()
and I also got saved column in state but cannot reorder it to default.
Have you looked at stateLoadParams?
dttblEnrolledUser = $('#tblUsers').dataTable({
...
stateLoadParams: function( settings, data ) {
if (data.order) delete data.order;
}
})
Will effectively reset the saved sorting order on each refresh.
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'},
I am trying to add a search field to my form in sencha touch 1.1, but after going through examples provided by sencha touch, i could not find out a way to provide a dynamic store to the search field.
I have a store which will fetch data dynamically.
The store contains list of places and when the user enters the first letter of the place,he should be given a list of places starting from that alphabet
Here is the code i have used.
var searchField = new Ext.form.Search({
name : 'search',
placeHolder: 'Search',
useClearIcon: true,
data:siteStore,
autoComplete:true,
});
inputDataForm = Ext.extend(Ext.Panel, {
scroll: 'vertical',
autoDestroy: true,
layout: 'fit',
id:'inputForm',
initComponent: function() {
this.items = [{
xtype: 'form',
cls: 'formClass',
id:'inputImageForm',
bodyPadding: '0',
scroll: 'vertical',
items: [searchField],
}];
inputDataForm.superclass.initComponent.call(this);
}, // End fo initComponent
});
Can somebody please help.
Thank you
This is my code. It is working fine and I have docked the searchfield in a panel.
You can use this and I am sure it works.
, dockedItems: [{
xtype:'searchfield'
, name: "searchfield"
, placeHolder: 'Search Patient'
, id: 'searchPat'
, listeners: {
keyup: function(me,e){
var searchData = me.getValue();
Ext.Ajax.request({
url:'your data url'
, params:{
filter: searchData
}
, scope: this
, success: function(res){
var rec = Ext.decode(res.responseText);
var def = typeof (rec.success);
if(def != "undefined" ){
this.store.removeAll();
this.store.loadData(rec.patients);
}
}
, failure:function(res){
console.log(res);
}
})
}
, scope: this
}
I am using extjs4,I need to add check box group based on my JSON Object,
JSON
{"Provider":[{"id":3,"name":"Beta House","npi":0,"taxId":0,
"address":{
"state":{"id":"1","stateName":"Alabama","code":"AL"},
"zipcode":0,"country":"USA","email":"beta#gmail.com"},
"type":"CP","LabProvider":[],"ListOfProvider":[]}]}
ExtJs
Ext.define('providerList', {
extend: 'Ext.data.Model',
fields: ['id','name']
});
var provider = Ext.create('Ext.data.Store', {
model: 'providerList',
autoLoad: true,
proxy: {
type: 'ajax',
url : url+'/lochweb/loch/clinicalProvider/getAll',
reader: {
type: 'json',
root: 'Provider'
}
}
});
Panel
var checkboxconfigs = [];
provider.each(function(record) {
checkboxconfigs.push(
{
boxLabel: 'record.id',
name: 'record.name'
})
});
var checkboxes = new Ext.form.CheckboxGroup({
fieldLabel:'Providers',
columns:2,
items:checkboxconfigs
});
var patientProvider = new Ext.FormPanel({
renderTo: "patientProvider",
frame: true,
title: 'Association',
bodyStyle: 'padding:5px',
width: 500,
items: [{
checkboxes
}],
});
There is no check box in the form.How to populate checkbox from JSON store
You can define the items array before you use it as children of checkboxes. Each element of items array is created base on each record of the store.
var items = [];
provider.each(function(record) { items.push({boxLabel: 'up-to-you', name: 'up-to-you'}) }, );
var checkboxes = new Ext.form.CheckboxGroup({
fieldLabel:'Providers',
columns:2,
items:items
});
Here you can determine the boxLabel and name for each checkbox (the attributes of record may be used as prefix, suffix...)
A couple of tips:
in the definition of panel items remove {} around checkboxes, like this:
items: [ checkboxes ]
second, make sure that the store is available when you are populating checkboxes.
I have a similar situation in my app where store is available after panel is rendered. Panel is dynamically populated with list of checkboxes like this:
panel.add(new Ext.form.CheckboxGroup({
columns: 1,
vertical: true,
items: checkItems
}));
panel.doLayout();
EDIT: another tip:
remove qutoes '' from this code:
{
boxLabel: 'record.id',
name: 'record.name'
}
or you will end up with all labels 'record.id'
I really hope someone can help me, It seems like this should be obvious but sencha documentation isn't very easy to read and incomplete. I am trying to build a search form but it doesnt seem to take the store or the url and I can't figure out how to add parameters like page? Can anyone help? This code just produces Failed to load resource: null.
var searchField = new Ext.form.Search({
value:'Search',
url: 'someurl',
store: this.data_store,
cls:'searchfield',
listeners: {
focus: function(){ searchField.setValue(''); },
blur: function(){ if( searchField.getValue()=='' ){ searchField.setValue('Search'); } },
success: function(e){
console.log(e);
}
}
});
this.dockedItems = [ searchField ];
Ext.form.FormPanel doesn't take a Ext.data.Store or Ext.data.Model directly but does deal with Instances of Ext.data.Model. Lets say you have the following model:
Ext.regModel('MyForm', {
fields: [{name: 'id', type: 'int'},'name','description']
proxy: {
type: 'ajax',
url: 'url_to_load_and_save_form'
}
})
Now your form definition would look something like this:
Ext.form.MyForm = Ext.extend(Ext.form.FormPanel, {
record : null,
model: 'MyForm',
items: [{
xtype: 'hidden',
name: 'id'
},{
xtype: 'textfield',
name: 'name',
allowBlank: false
},{
xtype: 'textarea',
name: 'description'
}],
submit : function(){
var record = this.getRecord() || Ext.ModelMgr.create({}, this.model);
this.updateRecord(record , true);
record.save({
scope: this,
success : function(record, opts){
this.fireEvent('saved', record);
},
callback: function(){
this.setLoading(false);
}
});
}
});
Ext.reg('MyForm',Ext.form.MyForm);
Of course you should add in some validations and a button to actually call the Ext.form.MyForm.submit method.