Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Title name of a field in a Dialog at runtime #941

Closed
rolembergfilho opened this issue Jul 19, 2016 · 9 comments
Closed

Change Title name of a field in a Dialog at runtime #941

rolembergfilho opened this issue Jul 19, 2016 · 9 comments

Comments

@rolembergfilho
Copy link
Contributor

rolembergfilho commented Jul 19, 2016

Hey

how can I change a title of a field (eg Product Name to Product Internal Name) at runtime?.

I tried to get the field with jquery, but without succes.

and tried with this.form.field.getGridField() and this.form.field.element.closest(".field"), without success too.

@jsbUSMC
Copy link

jsbUSMC commented Jul 20, 2016

Do you mean on the dialog or the grid? And do you mean the title of the dialog or grid, or a property field on the dialog or grid?

  • Title of a Grid: On top of your XYZEntityRow.cs class declaration you will see an attribute that says DisplayName("PluralEntities"). Changing the string inside of this DisplayName() attribute will change what is displayed as the title of the grid
  • Title of a Dialog: Similarly, next to the DisplayName() attribute on top of your entity class declaration you will see an attribute InstanceName("SingularEntity"). The string inside of this InstanceName() attribute will be displayed as the title of a new dialog

For property fields on the grid, decorate the property field whose column name you want changed with a [DisplayName("Product Internal Name")] attribute directly above it:

// ....
public class ProductColumns
{
    [DisplayName("Product Internal Name")]
    public string ProductName { get; set; }

    // ....
}

You can do the same thing for property fields on the XYZEntityForm.cs class as well to change the label for fields on a dialog form.

@rolembergfilho
Copy link
Contributor Author

Hey man !

I mean the title of a Dialog.

These step you told about is changing the title before the runtime. So, the title will be static. To change, I need to set the DisplayName property, build and run again.

I need to change the dialog field title during the runtime, when my user is editing the data.

Why? Here in Brazil we have 2 kind of ID: Personal ID (eg CPF), and Business ID (eg CNPJ).
to identify the name of Personal ID, my field title will show "NAME". But to identify Business ID, my field title must show "RAZAO SOCIAL", that is the name of the business registered in oficial documents.

@rolembergfilho rolembergfilho changed the title Change Title name of dialod Change Title name of dialog Jul 20, 2016
@rolembergfilho rolembergfilho changed the title Change Title name of dialog Change Title name of dialog at runtime Jul 20, 2016
@volkanceylan
Copy link
Member

Dialog has a dialogTitle property. Best place to set it is in updateTitle method of entity dialog.

@rolembergfilho
Copy link
Contributor Author

It's not working..

I tried
this.form.RazaoSocial.getGridField().text('MUDEI O NOME!!!');

and
this.form.RazaoSocial.getGridField().text(function (i, oldText) {
return oldText === 'Nome' ? 'Razão Social' : oldText;
});

but it replace all LINE to the changed text.

one idea that i have is how to get the id field at client side in run time (eg BELECH_Gestao_ClientesDialog10_NomeAbreviado)

@volkanceylan
Copy link
Member

What are you doing there. I said dialogTitle, not getGridField etc.

@volkanceylan
Copy link
Member

If you mean change title of field,

this.form.RazaoSocial.getGridField().find('.caption').text('asdadasd')

@rolembergfilho
Copy link
Contributor Author

=)

Almost close !!!

So, the command above worked when the caption field is not a required field

this.form.RazaoSocial.getGridField().find('.caption').text('asdadasd')

but, if the caption is a required field, the command above not working well, because he will erase the "*" (signal of required field).

So, in these case to change the title of required field, the command below works good :

var texto = this.form.RazaoSocial.getGridField().find('.caption').prop('outerHTML').split('Razão Social').join('Nome');
this.form.RazaoSocial.getGridField().find('.caption').prop('outerHTML', texto);

Thanks @jsbUSMC and @volkanceylan for your time and patience!

@rolembergfilho
Copy link
Contributor Author

PS.: For some reason, In typescript, String.Replace only replaces first occurrence of matched string.

So, I used the function split(oldtext).join(newtext)

@rolembergfilho rolembergfilho changed the title Change Title name of dialog at runtime Change Title name of a field in a Dialog at runtime Jul 21, 2016
@JohnRanger
Copy link

Hi all,

I have made a WIKI article out of this with a generic solution which does not need a hard-coded "old value".

Hope this helps someone.

With kind regards,

John

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants