Creating a simple Horizontal Grid

If you have a data class SomeData, then you can define a horizontal grid for it like this:

Horizontal grid definition

  public class HorizontalGridFullFeatured : HorizontalGridControlBase
  {
    public HorizontalGridFullFeatured()
    {
      View<SomeData>("View1",
        v1 =>
        {
          v1.AddColumn("Column1").BindToProperty(d => d.StringValue).And().WithSorting().Allowed();
          v1.AddColumn("Column2").BindToProperty(d => d.IntValue).And().WithEditing().NotAllowed().And().WithSorting().NotAllowed();
				}
		}
	}

Above definiton will produce following result:

SimpleHorizontalGrid.png

Creating a Master-Detail Grid

  public class HorizontalGridFullFeatured : HorizontalGridControlBase
  {
    public HorizontalGridFullFeatured()
    {
      View<SomeData>("View1",
        v1 =>
        {
          v1.AddColumn("Column1").BindToProperty(d => d.StringValue).And().WithSorting().Allowed();
          v1.AddColumn("Column2").BindToProperty(d => d.IntValue).And().WithEditing().NotAllowed().And().WithSorting().NotAllowed();
          v1.AddDetailView<SomeSubdata>("DetailView1",
            dv1 =>
            {
              dv1.BindToCollection(d => d.SubdataList);
              dv1.AddColumn("Column11");
              dv1.AddColumn("Column12").BindToProperty(d => d.Submember).And().WithFiltering().Allowed();
            });
          v1.AddDetailView<SingleHopClass>("DetailView2",
            dv2 =>
            {
              dv2.BindToCollection(d => d.ComplexSubdataList);
              dv2.AddColumn("Column21").BindToProperty(d => d.StringValue).And().WithFiltering().Allowed();
              dv2.AddColumn("Column22").BindToProperty(d => d.DhcProperty.ThcProperty.StringProperty).And().WithFiltering().NotAllowed();
              dv2.AddDetailView<DualHopClass>("DetailView21",
                dv21 =>
                {
                  dv21.BindToCollection(d => d.DhcList);
                  dv21.AddColumn("Column211", d => d.ThcProperty.StringProperty);
                });
            });
        });
    }
  }

Above definiton will produce following result:

MasterDetailHorizontalGrid.png

Creating a simple grid with object editing using a dropdown grid

  public class HorizontalGridFullFeatured : HorizontalGridControlBase
  {
    public HorizontalGridFullFeatured()
    {
      View<SomeData>("View1",
        v1 =>
        {
          v1.AddColumn("Column1").BindToProperty(d => d.IntValue).And().WithEditing().AllowedUsing()
            .Values(new int[] { 1, 1, 2, 3, 5, 8 });
          v1.AddColumn("Column2").BindToProperty(d => d.StringValue).And().WithEditing().AllowedUsing()
            .Objects<SomeSubdata>(new SomeSubdata[]{
              new SomeSubdata(){ Submember = "S1", Textmember = "TEXT1", Prop1 = "P11", Prop2 = "P12" },
              new SomeSubdata(){ Submember = "S2", Textmember = "TEXT2", Prop1 = "P21", Prop2 = "P22" },
              new SomeSubdata(){ Submember = "S3", Textmember = "TEXT3", Prop1 = "P31", Prop2 = "P32" }
            })
            .InDropdownGridEditor(
              de =>
              {
                de.DisplayProperty(d => d.Textmember);
                de.AssignValue().FromProperty(d => d.Submember);
                de.AddColumn("Cap1", d => d.Prop1);
                de.AddColumn("Cap2", d => d.Prop2);
              });
          v1.AddColumn("Column3").BindToProperty(d => d.Subdata).And().WithEditing().AllowedUsing()
            .Objects<SomeSubdata>(new SomeSubdata[]{
              new SomeSubdata(){ Submember = "S1", Textmember = "TEXT1" },
              new SomeSubdata(){ Submember = "S2", Textmember = "TEXT2" },
              new SomeSubdata(){ Submember = "S3", Textmember = "TEXT3" }
            })
            .InDropdownBoxEditor(
              de =>
              {
                de.DisplayProperty(d => d.Submember);
                de.AssignValue().FromObject();
              });
          v1.AddColumn("Column6").BindToProperty(d => d.Subdata.Submember);
        });
    }
  }

Above definiton will produce following result:

SimpleHorizontalGridObjectEditing.png

Last edited May 7, 2009 at 4:23 PM by sdesmedt, version 3

Comments

No comments yet.