Hello,
I want to add Google places autocomplete feature in batch edit cell. Any ideas to accomplish this?
Here is the code for adding autocomplete feature in a textbox :
also to include this
I want to add Google places autocomplete feature in batch edit cell. Any ideas to accomplish this?
Here is the code for adding autocomplete feature in a textbox :
var
searchTxt = (document.getElementById(
"textboxid"
));
var
searchBox =
new
google.maps.places.SearchBox(searchTxt);
google.maps.event.addListener(searchBox,
'places_changed'
,
function
()
{
// any action
});
<
script
type
=
"text/javascript"
src
=
"https://maps.googleapis.com/maps/api/js?libraries=places"
></
script
>
4 Answers, 1 is accepted
0
Jawwad
Top achievements
Rank 1
answered on 25 Dec 2014, 08:52 AM
The solution is putting a radtextbox in EditColumnTemplate and then adding it by id only once in Javascript.
Its working now. As you type, you will get the places predictions.
The second problem arises here, thats when I select (click on) any place from the prediction area, its pasted in the edit textbox but removes immidiately and the text i was entering to search shows.
For example
1. In edit textbox, I entered "ar".
2. Selected "Arizona" from prediction bar.
3. Arizona is pasted
4. Immidiately the text is again "ar".
I think some BatchEditEvent is causing this.
Any suggestions ?
Thanks in advance,
Jawwad
var
grid
= $telerik.findElement(document.body,
"myGrid"
);
var
txtAdd = $telerik.findElement(grid,
"txtAddress"
);
var srchBox =
new
google.maps.places.SearchBox(txtAdd);
google.maps.event.addListener(srchBox,
'places_changed'
,
function
()
{ // some action while predictions are changing
});
Its working now. As you type, you will get the places predictions.
The second problem arises here, thats when I select (click on) any place from the prediction area, its pasted in the edit textbox but removes immidiately and the text i was entering to search shows.
For example
1. In edit textbox, I entered "ar".
2. Selected "Arizona" from prediction bar.
3. Arizona is pasted
4. Immidiately the text is again "ar".
I think some BatchEditEvent is causing this.
Any suggestions ?
Thanks in advance,
Jawwad
0
Jawwad
Top achievements
Rank 1
answered on 25 Dec 2014, 08:53 AM
sorry its EditItemTemplate not EditColumnTemplate
0
Jawwad
Top achievements
Rank 1
answered on 25 Dec 2014, 11:08 AM
SOLVED
The code below worked. But if you think there is even more or simpler way, I will be glad to know that.
The code below worked. But if you think there is even more or simpler way, I will be glad to know that.
OnBatchEditGetEditorValue="GetEditorValue"
function
GetEditorValue(sender, args) {
if
(args.get_columnUniqueName() ==
"Description"
) {
args.set_cancel(
true
);
var
container = args.get_container();
var
newVal = $telerik.findElement(container,
"textboxid"
).value;
args.set_value(newVal);
}
}
0
Hello Jawwad,
In scenarios where you have more controls in the EditItemTemplate, you need to handle the events for getting and settings values from and to the editor and the cell. In some scenarios it is possible to override only one of the events, as in your project.
Having that in mind, handling the OnBatchEditGetEditorValue is the correct approach for retrieving the value that you need.
Best Regards,
Konstantin Dikov
Telerik
In scenarios where you have more controls in the EditItemTemplate, you need to handle the events for getting and settings values from and to the editor and the cell. In some scenarios it is possible to override only one of the events, as in your project.
Having that in mind, handling the OnBatchEditGetEditorValue is the correct approach for retrieving the value that you need.
Best Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.