This is a migrated thread and some comments may be shown as answers.

set business object after viewDidLoad

1 Answer 31 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mathieu
Top achievements
Rank 1
Mathieu asked on 10 Sep 2015, 12:48 PM

Hi,

I'm fetching business data from a server asynchronously ans thus I don't yet have access to the instance of a business object in viewDidLoad. So my setup code looks roughly like the following:

TKDataForm *dataForm = [[TKDataForm alloc] initWithFrame:self.view.bounds];
dataForm.delegate = self;
[self.view addSubview:dataForm];
 
self.dataSource = (TKDataFormEntityDataSource *)dataForm.dataSource;
 
[myDataSource executeQueryOnCompletion:^(id value) {
    self.dataSource.selectedObject = value;
}];

However, the problem is that no form will displayed whatsoever. The screen just stays empty. This if even reproducible by changing the example from the documentation such that the business object is set in viewDidAppear: instead of viewDidLoad:

 

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.dataSource.selectedObject = [PersonalInfo new];
}

So it looks like the business object has to be set in viewDidLoad by all means. This isn't very flexible, are there any ways around this limitation?

1 Answer, 1 is accepted

Sort by
0
Accepted
Adrian
Telerik team
answered on 10 Sep 2015, 03:44 PM
Hi Mathieu,

Thank you for contacting us.

I was able to reproduce the described issue. To workaround it you should invoke the reset method that is not visible in the public header of TKDataFormEntityDataSource using a selector after you set the selectedObject. Then you should call reloadData method of the data form. Please consider the code snippet below:
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    _dataSource.selectedObject = [PersonalInfo new];
     
    [_dataSource performSelector:@selector(reset)];
    [self.dataForm reloadData];
}

Please keep in mind that currently TKDataForm is beta and I can't guarantee that this will work after our next release. The described issue will be addressed in the next version of TelerikUI for iOS. Our next release is scheduled for the end of this month.

I hope this helps. If you need further assistance, do not hesitate to contact us.

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataForm
Asked by
Mathieu
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Share this question
or