Create Hierarchical view for Farpoint

Posted by: rajputamitd on 8 September 2017, 1:50 pm EST

  • Posted 8 September 2017, 1:50 pm EST

    Hi all,


    I am using Farpoint first time so please consider me.


    I want to set hierarchical view for Farpoint.Currently I am binding farpoint to a dataset.


     


    private void ConfigureGrid(DataSet dtShipper)


            {


               


                string[] strArray = new string[9] {"Company", "Type", "Location Name", "Address","Contact Name","Phone","Email","LocationId","ShipperId" };


     


                for (int i = 0; i < strArray.Length; i++)


                {


                    fpShip_Sheet1.ColumnHeader.Cells[0, i].Value = strArrayIdea;


                    fpShip_Sheet1.Columns.Get(i).Label = strArrayIdea;


                    fpShip_Sheet1.Columns.Get(i).Tag = strArrayIdea;


                }


     


                Common.ConfigGridHeader(fpShip, false, true);


                fpShip.Sheets[0].Columns[0, (strArray.Length - 1)].AllowAutoSort = false;


     


                fpShip.Sheets[0].AutoGenerateColumns = false;


                fpShip.Sheets[0].DataAutoSizeColumns = false;


                fpShip.Sheets[0].DataSource = dtShipper;


                fpShip.Sheets[0].Columns["Company"].DataField = "ShipperName";


                fpShip.Sheets[0].Columns["Company"].Width = 110;  //165;


     


                fpShip.Sheets[0].Columns["Type"].DataField = "ShipperType";


                fpShip.Sheets[0].Columns["Type"].Width = 70; //75;


     


                //fpShip.Sheets[0].Columns["Date"].DataField = "UpdatedDate";


                //fpShip.Sheets[0].Columns["Date"].Width = 200;


                //fpShip.Sheets[0].Columns["Date"].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;


     


                fpShip.Sheets[0].Columns["Location Name"].DataField = "LocationName";


                fpShip.Sheets[0].Columns["Location Name"].Width = 133; //200;


     


                fpShip.Sheets[0].Columns["Address"].DataField = "Address";


                fpShip.Sheets[0].Columns["Address"].Width = 300; //330;


     


                fpShip.Sheets[0].Columns["Contact Name"].DataField = "ContactName";


                fpShip.Sheets[0].Columns["Contact Name"].Width = 98; //110;


     


                fpShip.Sheets[0].Columns["Phone"].DataField = "Phone";


                fpShip.Sheets[0].Columns["Phone"].Width = 95; //100;


     


                fpShip.Sheets[0].Columns["Email"].DataField = "email";


                fpShip.Sheets[0].Columns["Email"].Width = 170;


     


                fpShip.Sheets[0].Columns["LocationId"].DataField = "LocationId";


                fpShip.Sheets[0].Columns["LocationId"].Visible = false;


     


                fpShip.Sheets[0].Columns["ShipperId"].DataField = "Shipperid";


                fpShip.Sheets[0].Columns["ShipperId"].Visible = false;


     


              


                //fpShip.Sheets[0].Columns["Is Active"].Formula = "IF('Is Active'<1,'In Active','Active')";


                //fpShip.Sheets[0].Columns["Shipper Name"].Width = 350;


                //fpShip.Sheets[0].Columns["Web URL"].Width = 250;


                //fpShip.Sheets[0].Columns["Date"].Width = 150;


                //fpShip.Sheets[0].Columns["Is Active"].Width = 70;


                for (int iShippRow = 0; iShippRow < fpShip.Sheets[0].Rows.Count; iShippRow++)


                {


                //    //fpShip.Sheets[0].Cells[iShippRow, 3].Formula = "IF(" + fpShip.Sheets[0].Cells[iShippRow, 3].Value + "<1,'In Active','Active')";


                   


                //    //fpShip.Sheets[0].Cells[iShippRow, 4].Value = imgModify;


                //    //fpShip.Sheets[0].Cells[iShippRow, 5].Value = imgDelete;


                //    //fpShip.Sheets[0].Cells[iShippRow, 4].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;


                //    //fpShip.Sheets[0].Cells[iShippRow, 5].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;


                //    string dd = dtShipper.Tables[0].Rows[iShippRow]["ShipperType"].ToString();


     


                    if (dtShipper.Tables[0].Rows[iShippRow]["ShipperType"].ToString() == "S")


                        fpShip.Sheets[0].Cells[iShippRow, 1].Value = "Shipper";


     


                    if (dtShipper.Tables[0].Rows[iShippRow]["ShipperType"].ToString() == "C")


                        fpShip.Sheets[0].Cells[iShippRow, 1].Value = "Consignee";


     


                    if (dtShipper.Tables[0].Rows[iShippRow]["ShipperType"].ToString() == "T")


                        fpShip.Sheets[0].Cells[iShippRow, 1].Value = "Third Party";


     


                //    if (fpShip.Sheets[0].Cells[iShippRow, 3].Value.ToString() == "Active")


                //        fpShip.Sheets[0].Cells[iShippRow, 3].Value = "Active";


                //    else


                //        if (fpShip.Sheets[0].Cells[iShippRow, 3].Value.ToString() == "InActive")


                //            fpShip.Sheets[0].Cells[iShippRow, 3].Value = "InActive";


                //        else


                //        if (Convert.ToInt32(fpShip.Sheets[0].Cells[iShippRow, 3].Value) == 1)


                //        fpShip.Sheets[0].Cells[iShippRow, 3].Value = "Active";


                //        else


                //        fpShip.Sheets[0].Cells[iShippRow, 3].Value = "InActive";


     


                    fpShip.Sheets[0].Cells[iShippRow, 6].ForeColor = System.Drawing.Color.Blue;


                    fpShip.Sheets[0].Cells[0, 0, fpShip.Sheets[0].RowCount-1, 6].Locked = true;


                }


               


            }


     

  • Replied 8 September 2017, 1:50 pm EST


    dsShipper = new DataSet();


    dsShipper = objShipper.GetShipInfo("All");


    ConfigureGrid(dsShipper);


     where GetShipInfo is a Stored procedure.


    Is there anything I need to provide?

  • Replied 8 September 2017, 1:50 pm EST

    Hello Johny, 

    Attached is the sample that you are looking for. 

    Regards, 


    2009/04/HierarchyCS.zip
  • Replied 8 September 2017, 1:50 pm EST

    Thanks Harish,


    That's great.But can you give me the code of binding from database.Here they are using arraylist.


    That will be a great help.

  • Replied 8 September 2017, 1:50 pm EST

    Hello,


    In order to get the hierarchial view in the Spread by default, you need to make sure there are multiple related tables in dsShipper. You can look at the Hierarchy sample that ships with the product to see how to bind the Spread to a DataSource with related DataTables to get a hierarchial view of the data.

  • Replied 8 September 2017, 1:50 pm EST

    I have added multiple related tables in dsShipper.


    The code you are asking me to view is in VB, can I havve C# syntax?

  • Replied 8 September 2017, 1:50 pm EST

    I am not getting that '+',with which I can get the ChildViewCreated().


    I have set the relation in dataset and set the dataset as the datasource for farpoint

  • Replied 8 September 2017, 1:50 pm EST

    Please ensure that you have added the Relation to your DataSet and you are binding the Spread to DataSet and not the DataTable. Below is the code that shows binding the spread to generate the hierarchial view using Nwind database. 

    DataAdapter.SelectCommand.CommandText="Select * from Catetgories";

    DataAdapter.Fill(DataSet,"Categories");

    DataAdapter.SelectCommand.CommandText="Select * from Products";

    DataAdapter.Fill(DataSet,"Products");

    DataSet.Relations.Add("Root", ds.Tables("Categories").Columns("CategoryID"), ds.Tables("Products").Columns("CategoryID")) 

    FpSpread1.DataSource=DataSet;

    Regards,

  • Replied 8 September 2017, 1:50 pm EST

    Thanks Harish S.


    I have set the Sheet's ColumnCOunt property under RowHeader to 1.


    Now I am getting the hierarchical view.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels