Serenity: How to create a male or female icon according to the gender

Created on 10 Jan 2017  路  3Comments  路  Source: serenity-is/Serenity

I am trying to re-create the male or female icon that is displayed with the employee name in Northwind forms according to employee gender. It seems to be very complicated. Is there a description of this implementation?

Most helpful comment

Look at the Northwind Sample. Specifically Employee row, gender.cs and the employeeformatter.cs.

It's very straight forward.

All 3 comments

Look at the Northwind Sample. Specifically Employee row, gender.cs and the employeeformatter.cs.

It's very straight forward.

@dkontod samples are there for you to not ask these questions.

Hello i am used the following code to display the icon of Gender in Grid.

@Serenity.Decorators.registerFormatter([Serenity.ISlickFormatter, Serenity.IInitializeColumn])
export class PensionersFormatter implements Slick.Formatter {
    format(ctx: Slick.FormatterContext) {
        var text = Q.htmlEncode(ctx.value);

        if (!this.genderProperty) {
            return text;
        }

        var gender = ctx.item[this.genderProperty];
        return "<span class='" + ((gender === OnlinePVA.Modules.Default.Titles.Gender.Female) ?
            'employee-symbol female' : 'employee-symbol male') +
            "'>" + text + '</span>';
    }

    @Serenity.Decorators.option()
    public genderProperty: string;

    public initializeColumn(column: Slick.Column) {
        column.referencedFields = column.referencedFields || [];
        if (this.genderProperty)
            column.referencedFields.push(this.genderProperty);
    }

But it does not working.( I Reffered the Northwind Samples ).
Let me know any changes in above code.

Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kilroyFR picture kilroyFR  路  3Comments

GitHubOrim picture GitHubOrim  路  3Comments

JohnRanger picture JohnRanger  路  3Comments

ga5tan picture ga5tan  路  3Comments

ahsansolution picture ahsansolution  路  3Comments