Row Expander checking condition - extjs4

I have Grid with "rowexpander". with this I am able to expand the row, and able to show the content .i.e. html checkbox.
Now my requirement is the in my DB I got the value true or false. So depending upon the value i.e. true I want show check box with checked.
Here is my code.
plugins: [
{
ptype: 'rowexpander',
rowBodyTpl:
['<ul><li><input type="checkbox" name="" checked={marginAccess} ><span>Margin Access for Quote</span></li></ul> ']
}
Now {marginAccess} when is it true I want to show ""
i.e. checked = checked
I am not able to do this, Can you please suggest me ?

Create a virtual member in your model. One which will return 'checked/unchecked' for true/false value of other field. Like this:
{ name: 'marginAccess_str', type: 'string', convert: function(v, r) {
if (r.get('marginAccess'))
return 'checked';
else
return 'unchecked';
}},
And then use marginAccess_str in your template.

Related

Cannot set a checkbox unchecked once it has been checked against the data with Vue

I am desparately trying to understand what's wrong there and can't figure it out!
I'll try to explain as best as I can, but the code is lengthy and I can't post it easily.
I have a component called "FrameHeader" that includes an input checkbox. This component is called in another component called "Frame", and the frames made from a v-for in another component ("FrameContainer").
In FrameHeader template, I have this:
<input :key="'frame-touchselectbox-'+frameId" type="checkbox"
v-model="touchSelected"
:class="{hidden: !isTouchSelectOn, selectCheckBox: true}"
/>
touchSelected is a computed property defined as such:
computed: {
touchSelected() {
console.log("checking frame touch selected for frame " + this.frameId + " ==> " + store.getters.isFrameTouchSelected(this.frameId));
return store.getters.isFrameTouchSelected(this.frameId);
},
},
where store.getters.isFrameTouchSelected(this.frameId); retrieves a boolean property called "touchSelected" in an object of the state:
The idea is that in the scenario I have, all "touchSelected" properties are first set to false (A), then only the one from one of the frame is set to true (B).
(A):
toggleTouchSelect(state, payload: {frameId: number; toggle: boolean}) {
const newCandidates: number[] = (payload.toggle) ? getAllSiblings(state.frameObjects, payload.frameId): [];
Object.keys(state.frameObjects).forEach((frameKey) => {
Vue.set(
state.frameObjects[parseInt(frameKey)],
"touchSelected",
false
);
Vue.set(
state.frameObjects[parseInt(frameKey)],
"isTouchSelectOn",
newCandidates.includes(parseInt(frameKey))
);
});
},
(B):
touchSelectFrame(state, payload: {frameId: number; isSelected: boolean}) {
Vue.set(
state.frameObjects[payload.frameId],
"touchSelected",
payload.isSelected
);
},
The data I get in the store is correct, I get false/true values where I want them.
However, the checkboxes are not correct. The first time I set one of the frame's property to "true", the corresponding checkbox gets checked. But when I get another frame's property to "true", the previous frame's checkbox doesn't get unchecked. Actually, I see it first being unchecked, then being checked again.
As I said, the data in the state is correct: even when that checkbox revert to checked, the underlying property in the data for that frame is "false".
BUT the weirdest thing is that if only change the checkbox input to a text input (changing the type of the input in the template), the text value is always correct even after the second time I set a frame's property to "true".
So...i'm totally puzzled and can't understand what's happening with those checkboxes.
Sorry for the vague explanation I hope it can still be understandable and that someone will shed a light on that :) Thanks a lot.
Computed props are by default getter-only (reference). That means your checkbox can read the value of touchSelected but can't change its value. You have to use a computed prop with a getter AND a setter. Assuming you have a mutation to change your frameId logic in Vuex:
computed: {
touchSelected: {
get(): {
return store.getters.isFrameTouchSelected(this.frameId);
}
set(newValue): {
store.commit('FRAME_MUTATION', newValue);
}
}
},

KeystoneJS dependsOn not saving its new value when disappear

User.add({
name: { type: Types.Name, required: true },
userid: { type: Types.Text, initial: true, required: true },
exceed_login_attempt: {
type: Types.Boolean,
default: false,
label: 'Exceeded Invalid Login Attempts',
dependsOn: { exceed_login_attempt: true }
}
});
I have here a checkbox input field exceed_login_attempt I want this to be display in AdminUI if the value is true (checked). If I unchecked that the value is false and the checkbox will disappear - this is fine.
But when I save it the checkbox value which is false is not save. After rendering the page the value is still true, which means it displays again the checkbox.
On KeystoneJS database documentation it is mentioned that:
To improve the usability of the Admin UI, it is possible to hide fields when no value is set, or depending on the value of other fields.
A field can depend on the value of other fields. But in your posted code, the exceed_login_attempt field, depends on its own value, which doesn't look right to me:
exceed_login_attempt: {
...
dependsOn: { exceed_login_attempt: true }
}
I'm not sure, maybe you intend to use collapse rather than dependsOn:
collapse [Boolean] Displays an + add link in the admin UI when the field has no value. Will completely hide field UI when noedit is also set to true, when the field has no value

AnyColumn option added as new column in Dojo enhanced grid view

I am working on dojo enhanced grid view. I am able to display the grid in UI. But AnyColumn option is added as new column.
Example:
Any help will be appreciated...
Here is the Code
var mygrid = new EnhancedGrid({
id: "grid",
store: gridStore, //Data store passed as input
structure: gridStructure, //Column structure passed as input
autoHeight: true,
autoWidth: true,
initialWidth: width,
canSort : true,
plugins: {
filter: {
//Filter operation
isServerSide: true,
disabledConditions : {"anycolumn" : ["equal","less","lessEqual","larger","largerEqual","contains","startsWith","endsWith","equalTo","notContains","notEqualTo","notStartsWith","notEndsWith"]},
setupFilterQuery: function(commands, request){
if(commands.filter && commands.enable){
//filter operation
}
}
}
}, dojo.byId("mydatagrid"));
mygrid.startup();
Thanks,
Lishanth
First, do not use EnhancedGrid, instead use either dgrid or gridx.
I think by default anycolumn is added to the dropdown. If you want to remove then, I would suggest to
Register for click event on the filter definition
Iterate through the drop-down and remove the first entry which is anyColumn
or you can also try something like
dojo.forEach(this.yourgrid.pluginMgr.getPlugin('filter').filterDefDialog._cboxes, function(dropdownbox) {
dropdownbox._colSelect.removeOption(dropdownbox.options[0]);
});
Updated answer is. I know this is not the elegant way of doing it but it works.
//reason why I'm showing the dialog is that _cboxes of the filter are empty initially.
dijit.byId('grid').plugin('filter').filterDefDialog.showDialog();
dojo.forEach(dijit.byId('grid').pluginMgr.getPlugin('filter').filterDefDialog._cboxes, function(dropdownbox) {
var theSelect = dropdownbox._colSelect;
theSelect.removeOption(theSelect.options[0]);
});
//Closing the dialog after removing Any Column
dijit.byId('grid').plugin('filter').filterDefDialog.closeDialog();

Dojo: Select of empty value for FilteringSelect while required=false

Please look on this code:
dojo.require('dijit.form.FilteringSelect');
dojo.require('dojo.store.JsonRest');
dojo.declare('JsonFilteringSelect', dijit.form.FilteringSelect, {
constructor: function (options) {
dojo.declare.safeMixin(this, options);
if (this.url) {
this.store = new dojo.store.JsonRest({
target: this.url
});
} else {
console.log('JsonFilteringSelect: options.url is not defined');
}
}
});
var getPersonJsonFilteringSelect = new JsonFilteringSelect({
url: '/person/get',
name: 'Test',
title: 'Test title',
required: false,
autoComplete:false,
value: '',
pageSize:10,
queryExpr:'${0}'
}, dojo.byId('select'));
getPersonJsonFilteringSelect.startup();
});
Use case: Suppose I have 20 results into my FilteringSelect.
User selects 1 value of FilteringSelect.
This value set as value of
FilteringSelect.
But after user decides to change this value on
empty value.
As I understand, because required:false FilteringSelect should allow
to set empty value, but it is not. I observe this behavior here:
User clicks FilteringSelect textbox
User clears it
While user presses "Tab" or clicks by other element - FilteringSelect automatically selects first value.
How could I allow user to set empty value into FilteringSelect?
You should add an empty entry ("" or null maybe? I know "" works) to your data store after it's loaded (I'd put it at the beginning) but before startup of the widget.
The "required" issue is strange with FilteringSelect because it won't let you select any arbitrary value -- it has to be an entry from the data store. Yet, if it's not required shouldn't it not care?... Dojo is strange sometimes.

rally search user by first character

I want to realize the functionality that we can search the users' name by typing in the first character of their names. I need to use Javascript to create a custom html.
Is there anyone who has done this before could help me?
In the example from this repository, a user combobox Rally.ui.combobox.UserComboBox searches for matching values dynamically based on the first couple of characters.
This default functionality displays the expected values after the second character is entered.
var u = Ext.create('Rally.ui.combobox.UserComboBox',{
id: 'u',
project: project,
fieldLabel: 'select user',
listeners:{
ready: function(combobox){
this._onUserSelected(combobox.getRecord());
},
select: function(combobox){
this._onUserSelected(combobox.getRecord());
},
scope: this
}
});
this.add(u);
},
If you want to load all users (do not limit the selection to team members and editors of a specific project) you may use Rally.ui.combobox.Combobox instead of Rally.ui.combobox.UserComboBox, and set the model to User. But to workaround a default behavior where only the current user populates the combobox, use a filter that would filter in all users. In the example below ObjectID > 0 is used. This combobox will be populated by all users independently of the project picker. This fragment is not a part of a custom app example above:
{
xtype: 'rallycombobox',
fieldLabel: 'select project',
storeConfig: {
autoLoad: true,
model: 'User',
filters:[
{
property: 'ObjectID',
operator: '>',
value: 0
}
],
sorters: [
{
property: 'UserName',
direction: 'ASC'
}
]
}
}
You'll want to use the Web Services API. Here's how I would do it...
The API doesn't allow you to specify a placement of a character in the filter, but you can require that it exists somewhere in the name, that filter would look like:
[{
property : "FirstName",
operator : "contains",
value : "A" //Whatever letter you're looking to start with
}]
Now, once the store is loaded, use a second function to filter the records to only those which start with your character:
store.filterBy(function(item) {
return item.get("FirstName")[0] === "A";
});
Hope this helps :)