Hello,
I have implemented a shift scheduler with combobox for my association.
My combobox allow me to show people with custom roles (ruoli)(.
This is my example if I see Saturday 1 (Sab 1 in italian) on shift 14:00 - 20:00
I have selected for row with role A "Alex Corti"
if I open row with role CE role combobox I see (it's correct) that my person is disabled because I have selected him for previous row. So I can't select him with mouse
Otherwise If I write his name the browser allow me to insert him, but this behaviour is not what I want
So I write this portion of code onChanged events
This portion of code allow me to prevent the changed into my DB (I didn't call the API) but I can't
empty the combobox.
Could you help me to prevent the change on the browser.
What i want is:
If the previous combobox value is blank I want blank
If the previus combobox value is "Paolo Rossi" I want "Paolo Rossi"
Thanks Alex
|
export class Filtering extends SampleBase {
constructor() {
super(...arguments);
this.temp = 'countries';
this.state = { value: 'AU' };
//define the filtering data
this.searchData = data[this.temp];
// maps the appropriate column to fields property
this.fields = { text: 'Name', value: 'Code' };
// filtering event handler to filter a Country
this.onChange = (e) => {
this.setState({
value: e.value,
});
};
}
render() {
return (
<div className="control-pane">
<div className="control-section">
<div id="filtering">
<ComboBoxComponent
id="country"
ref={(ComboBox) => {
this.listObj = ComboBox;
}}
value={this.state.value}
dataSource={this.searchData}
fields={this.fields}
change={this.onChange.bind(this)}
placeholder="Select a country"
popupHeight="270px"
/>
<label>second combobox</label>
<ComboBoxComponent
id="country1"
ref={(ComboBox) => {
this.listObj1 = ComboBox;
}}
value={this.state.value}
dataSource={this.searchData}
fields={this.fields}
placeholder="Select a country"
popupHeight="270px"
/>
</div>
</div>
</div>
);
}
}
|
Hi Sureshkumar P ,
Your portion of code copy the value selected in combo 1 into combo 2. It's not my goal.
I think that you didn't undetstand my problem: I'm sorry I think I have not been clear.
I try to re-explain it again with simple case.
What I want is different.
As I written I have
- combo A with some values
- combo B with some values
- combo A could have the same values of combo B (and viceversa)
When I selected a vaule X of combo A, combo B show me all the values but disable the selected value on combo B (or viceversa).
I copied the code from official documentation and It's work. But it's work only if I use the mouse , but not If I input data with keyboard.
What i want is:
- I select value (X) on combobox A
- The combobox B don't allow me to select the same value selected in A (I have copied the code from documentation and it works for mouse, but not If I input data from keyboard).
So I have to write additional portion of code because If I write the value with the keyboard the combobox B allow me to insert the value X even if it's disabled by code.
This is not correct.
I added code for change event: but it's not work because it's not correct (I set e.cancel = true)
I attached my code but it's not work.
What I want is very simple:
I selected Alex Corti from combobox A
If I select Alex Corti from combobox B (using mouse) the browser doesn't allow to select it (it's correct)
But If I input with keybord Alex Corti into combobox B (see my image) the browser allow to insert it (but it's not correct for me)
So what I want is:
If the previous combobox B value is blank I want blank
If the previus combobox B value is "Paolo Rossi" I want "Paolo Rossi"
I want to restore the previous value
I hope my second explanation is much cleare than first one
Thanks Alex
|
this.onOpen = (e) => {
setTimeout(function (e) {
// get the second combobox value
var otherValue =
document.getElementById('country1').ej2_instances[0].value;
var ddlObj = document.getElementById('country').ej2_instances[0];
// get the first combobox popup list element
let lis = ddlObj.popupObj.element.getElementsByTagName('li');
for (let li of lis) {
let value = li.getAttribute('data-value');
if (otherValue === value) {
li.classList.add('e-disabled');
li.style.pointerEvents = 'none';
if (otherValue === ddlObj.value) {
// if you enter the input value as same as disabled value then reset the value.
ddlObj.value = null;
}
}
}
}, 50);
};
|
Hi,
Your example has the same problem of my code.
You can enter the same value "Australia" for both combobox using keyboard.
Your portion of code is the same of mine (it's on documentation: avoid only mouse selection)
You can avoid to select "Australia" by mouse but not avoid to select "Australia" by keyboard.
Maybe I'm not so good with english but I think my goal is clear:
AVOID TO SELECT THE SAME VALUE BY USING THE KEYBOARD.
I think that I have to write portion of code onChange Event but I don't know how.
I can set to null the object and not save the value on db, but my final user see "Australia" and so for him the selection is "Australia", but it's not correct.
He told me:
Why you avoid the selection but I can bypass the control by editing by keyboard?
Thanks Alex
Hi Ponmani Murugaiyan,
thanks
Alex