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

TkEntityProperty editorClass

1 Answer 22 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.
Ryan
Top achievements
Rank 1
Ryan asked on 11 Apr 2017, 10:08 PM
Currently if a TKEntityProperty for the dataform is set for read only with TKEntityPropertyTypeString the dataform uses un-editable TKTextFields to display the data. Is there an editorClass for the TKEntityProperty where I can have UILabels being displayed instead? I want the data form to use UILabels because I have an objective-c category for UILabels that allows me to add copy to pasteboard functionality for labels. I need these values displayed to be copyable.

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 12 Apr 2017, 08:10 AM
Hello Ryan,

Thank you for writing. Indeed having UILabels to display the property value when in read only mode is a nice suggestion. I have logged it in our feedback portal. Currently, as we don't have such editor, you can use the TKDataFormCustomEditor, which allows you to choose the type of UIView that is used as editor:

_dataSource[@"propertyName"].editorClass = [TKDataFormCustomEditor class];

Then in the setupEditor method of the TKDataFormDelegate you can assign a delegate to the editor:

-(void)dataForm:(TKDataForm *)dataForm setupEditor:(TKDataFormEditor *)editor forProperty:(TKEntityProperty *)property
{
    if ([property.name isEqualToString:@"propertyName"]) {
        TKDataFormCustomEditor* customEditor = (TKDataFormCustomEditor*)editor;
        customEditor.delegate = self;
    }
}

And provide an UILabel as UIView in the proper TKDataFormCustomEditorDelegate methods:

-(UIView *)editorWillCreateView:(TKDataFormCustomEditor *)editor
{
    UILabel* label = [[UILabel alloc] init];
    return label;
}
 
-(NSObject *)editorWillReturnValue:(TKDataFormCustomEditor *)editor editorView:(UIView *)view
{
    return ((UILabel*)view).text;
}
 
-(void)editor:(TKDataFormCustomEditor *)editor shouldApplyValue:(NSObject *)value editorView:(UIView *)view
{
    ((UILabel*)view).text = (NSString*)value;
}

Let us know if you need further assistance.

P.S. I have updated your Telerik points for the given suggestion. Thank you!

Regards,
Todor
Telerik by Progress
Want to build beautiful Android apps as well? Check out UI for Android which enables the same set of scenarios, allowing you to create the same great app experience on both iOS and Android.
Tags
DataForm
Asked by
Ryan
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or