lundi 10 août 2015

Resizing Tokens

First of all, I am working with DevExpress Mvc version

I am currently working on replacing a custom control where we had a Drop-Down Edit Box with a List Box inside with a Token Box. Currently, the Token Box is on the page and works, however, when I prepopulate it, the Tokens shrink up.

Below is the code I'm using to populate them.

Html.DevExpress().TokenBox(settings =>
                    settings.Name = "tbox" + item.Id + "_" + item.FieldName;

                    settings.Properties.AllowCustomTokens = false;
                    settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
                    settings.Properties.ShowDropDownOnFocus = ShowDropDownOnFocusMode.Always;
                    settings.Properties.TextField = item.DataSource.TextField;
                    settings.Properties.ValueField = item.DataSource.ValueField;

                    if (Session["LIB" + item.FieldName] != null)
                        settings.Properties.Tokens.Add(Session["LIB" + item.FieldName].ToString());

                    settings.Properties.ClientSideEvents.Init = "OnTokenBoxSelectionChanged";
                    settings.Properties.ClientSideEvents.TokensChanged = "OnTokenBoxSelectionChanged";

Below is my javascript that goes with the code above.

function OnTokenBoxSelectionChanged(s) {        

    var id =,"_"));
    var name ="_") + 1);

    modJson[name] = { Id: id, Name: name, Value: s.GetValue() };

As I mentioned, I can put the data into the Token Box, however, the Tokens when preloaded come out messed up. If anyone has any idea on how to resize the Tokens to the full length of text, I would appreciate it. Thanks.

Aucun commentaire:

Enregistrer un commentaire