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

How to make a Flat TreeDataGrid Editable with dynamic values from a dictionary #228

Open
sps014 opened this issue Oct 22, 2023 · 2 comments

Comments

@sps014
Copy link

sps014 commented Oct 22, 2023

Hi,
I have the following code to add columns , after trying various combination for hours i am still failing to make text editable.

Source = new FlatTreeDataGridSource<EntityViewModel>(Entries);


Source.Columns.Add(new TextColumn<EntityViewModel, string>(nameof(EntityViewModel.Key), x => x.Key, null, new()
{
    IsTextSearchEnabled = true,
    BeginEditGestures =BeginEditGestures.Tap,
    CanUserSortColumn = true
}));

foreach(var c in Languages)
{
    var header = c == string.Empty ? "Neutral" : c;
    Source.Columns.Add(new TextColumn<EntityViewModel, string>(header, x => x.CultureValues[c],null, new()
    {
        IsTextSearchEnabled = true,
        BeginEditGestures = BeginEditGestures.Tap,
        CanUserSortColumn = true,
        TextTrimming= TextTrimming.CharacterEllipsis,
        MaxWidth=new GridLength(300,GridUnitType.Pixel)
    }));
}

here is my class whose items are populated.

public class EntityViewModel
{
    public string? Key { get; set; }
    public Dictionary<string, string?> CultureValues { get; set; } = new();

    public EntityViewModel(Entity entity)
    {
        foreach(var culture in entity.Cultures)
        {
            CultureValues.Add(culture,entity.GetValue(culture));
        }
    }
}

I supose Editing was implemented with #162 .

Thanks.

@SvonsySvonson
Copy link

Tried to make Text Column Cells editable in the same way, had the same issue. I got TreeDataGrid NuGet Package 11.0.2

@SvonsySvonson
Copy link

I can't make to work even F2 gesture

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

2 participants