Hi,
I am trying to customize the appearance of the cells in the listView of the AutoCompleteTextView. In my case, for example, I would like to have two lines of text with different information.
In order to do so, I have seen it is possible to use set the initCell and createCel from TKDataSourceListViewSettings, but this seems to have no effect in this case. Am I doing something wrong?
4 Answers, 1 is accepted
You can provide custom cell for the suggestions listview of the AutoCompleteTextView.
Consider the following code snippet.
_listView = (TKListView*)self.autocomplete.suggestionView;
[_listView registerClass:[MyCustomCell class] forCellWithReuseIdentifier:@"cell"];
TKListViewGridLayout *layout = [TKListViewGridLayout new];
//setup layout..
_listView.layout = layout;
You can get the listview and change the type of cells it uses, you can also change the layout of the TKListView.
In case you need detailed example of this, you can check our sdk examples. Here is link to the repo, the AutoCompleteCustomization example shows how to provide custom cell for the listview.
Regards,
Sophi
Telerik
Hi Sophi,
I know it is possible to do it by registering a custom cell, but I was wondering if there was anything more "automatic".
I mean, in my case I want to have a custom cell with two labels, so in order to initialize it I need also to implement a delegate to TKListViewDataSource and so listView:cellForItemAtIndexPath: (necessary) and listView:numberOfItemsInSection:. While the first one is necessary, the second one is just an unnecessary method to implement in my opinion.
If it was possible just to create customize the cell in the DataSource with initCell and createCell one wouldn't need to implement the delegate TKListViewDataSource at all. Besides, when using the delegate one needs also to expose the underlying list containing the objects to show, and this is an utter duplications in my opinion.
At this moment there is no "automatic" way. What you are suggesting here is quite handy and easy way to provide inner implementation for the datasource with no need to actually implement its methods.
It will be considered as a feature of the TKAutoCompleteTextView and possibly implemented.
In order to track the feature request I have created issue in the feedback portal based on your suggestion.
Here is the link to the issue and I am also adding 500 points to your Telerik account.
Thank you for your valuable feedback and suggestions.
Regards,
Sophi
Telerik
Hi Sophi,
Thanks for your help. At leas now I am sure that I'm not missing any hidden functionality :)