Home > Mobile >  How to refresh Grid when I add element in List - Blazor?
How to refresh Grid when I add element in List - Blazor?

Time:03-03

I have one list to make bind, i add elements to list but i cannot show items in Grid.

I have this code:

public List list= new List() { }; list.Add(new Test() {name = "xpto"} );

public class Test
{
    public string name{ get; set; }
}

<SfGrid DataSource="@list">
     <GridColumns>
       <GridColumn Field=@nameof(Test.name) HeaderText="Name"</GridColumn>
     </GridColumns>
</SfGrid>

But i got nothing in SfGrid.

CodePudding user response:

You are missing the GridColumns element:

<SfGrid DataSource="@list">
     <GridColumns>
         <GridColumn Field=@nameof(Test.name) HeaderText="Name"></GridColumn>
     </GridColumns>
</SfGrid>
  • Related