UI-Bootstrap typeahead doesn't work in editable grid
Hi guys, I'm using the ui-bootstrap inside my grid and hitting some issues, I've read through #3115 but the plunker in the solution doesn't seem right. http://plnkr.co/edit/ai91kJMiApXktc4vM4mt?p=preview Try typing 'New' in the first row then hitting enter to select 'New Hampshire', nothing happens.
I'm seeing the same behaviour in my app, no keyboard select or mouse select will work to choose a drop down item. Any ideas?
Hi, call to 'data-typeahead-on-select="typeaheadSelected(row.entity, $item)" ' also doesn't work. I think it is related to the autocomplete.
I'm not sure that's currently supported, I think someone would have to dig through it. No doubt we're trapping the enter key and using it for something else, so you might need to dig through the code and work out where. At a guess I'd say the edit feature is trapping it.
Using this cell template with appScope still typeahead very consufed
<form name="inputForm"> <div class="typeaheadcontainer"><input type="text" ' +
'class="typeaheadcontrol" ' +
'ui-grid-editor ' +
'data-ng-model="grid.appScope.mymodel" ' +
'data-typeahead="name as state.name for state in grid.appScope.states | filter:$viewValue | limitTo:8" ' +
'data-ng-required="true" ' +
'data-typeahead-editable ="false"' +
//'data-typeahead-on-select="grid.appScope.typeaheadSelected($item, $model, $label)" ' +
'/></div></form>
I have tracked it down inside typeahead ui-bootstrap-tpls.js
} else if (evt.which === 13 || evt.which === 9) {
scope.$apply(function () {
scope.select(scope.activeIdx);
});
}
Something is wrong with the scope and type ahead fails to call select and if I modify this to
ui-bootstrap-tpls.js
} else if (evt.which === 13 || evt.which === 9) {
scope.select(scope.activeIdx);
scope.$apply(function () {
scope.select(scope.activeIdx);
});
}
then inside select it fails to workout selected text
model = parserResult.modelMapper(originalScope, locals);
So it seems grid.appScope is the issue.
Would be awesome to get typeahead working with ui-grid as I am currently looking for other options like jquery autocomplete and not looking forward for that.
+1 I'm stuck on this too, and can't find a work-around; frankly it is beyond my DOM expertise.
Yes that would be awesome to get typeahead working with ui-grid however I've started on jquery ui autocomplete integration and creating a custom directive for binding so far its going ok, much easier than getting typeahead to work properly without modifying the core. I hope one day this would get done with typeahead would even pay for this feature.
+1
scope.$apply(function () {
scope.select(scope.activeIdx);
});
The inside "select" is not executed in my situation.
scope.select(scope.activeIdx);
scope.$apply();
Putting the "select" outside $apply can have "enter" key working, but the mouse click takes no effect.


Yeah same results here, that handsontable that you have mentioned does look promising, let me know how that goes
The $apply funciton is "noop" when working with ui-grid together. That's the reason the inner line can not be executed I think.

It should be something like this,

The "$apply" is "noop" only when lines below executed:
scope.$apply(function () {
scope.select(scope.activeIdx);
});
Quite strange
On "enter" "keydown",

stopEdit is called and which will destroy the originalScope

So the $apply of scope in the lines below will be noop after originalScope is destroyed.

So is it possible to write hack to overwrite endEdit?
The event should be bubbled from the inner typeahead to the outer ui grid I think. But the actual direction is contrary. I'm looking for the cause. The solution should be, the keydown handler of typeahead is executed before the keydown handler of ui grid.


Seems the event bind to the same element, and ui grid bind the event earlier than typeahead. Follow the rule First come and first out(See here), the event handler bind in ui grid will be executed firstly.
The solution 2 here can resolve this problem. But need tests to make sure other functions are not affected.

This is not the best solution I think. A better way should be capturing keydown event on typeahead popup and process the logic to change the model then propagate the event to ui-grid.
not sure if this will help, but I had a similar problem with angular ui-grid edit with typeahead autocomplete.
i could not select values from the list with my mouse until I used
typeahead-select-on-blur="true"
I'm not sure what is the issue here - I was able to get it to work here.
@wesleycho Issue is that model data does not gets bind. Try to bind object then see if that objects gets changed it won't. See my comments above.
(grid.appScope.typeaheadSelected($item, $model, $label))
Not only that typeahead has to visually work but also it should be able to bind models appropriately. I hope this helps