Fill tree with data from database table (NTreeDataSourceImporter)


Fill tree with data from database table (NTreeDataSourceImporter)
Author
Message
ldhbflhd ljksfdbld
ldhbflhd ljksfdbld
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)
Group: Forum Members
Posts: 2, Visits: 1
Hello,

I am trying to fill some data from my table in DB where I have ID and ID_PARENT connection.
SAMPLE:
ID ID_PARENT NAME
1 -1 BOSS (I tried root id_parent also null, 0, some number...)
2 1 JOHN
3 2 MIKE
4 2 SUE
....
I can't get it working, can any help ? The problem is, because treeimport_ImportFailed is thrown and I don't know why.

Here is my code. THX

Any other working example ?


protected void ImportTree()
{
DataClassesDataContext db = new DataClassesDataContext();
var izbrani = from f in db.VrniStrukturo(847)
select f.id_sodelavec;

var sod = from s in db.sodelavecs
where izbrani.Contains(s.id_sodelavec)
select s;

// clear the document
NDrawingView1.Document.ActiveLayer.RemoveAllChildren();

NTreeDataSourceImporter treeimport = new NTreeDataSourceImporter();
treeimport.Document = NDrawingView1.Document;
treeimport.DataSource = sod;
treeimport.IdColumnName = "id_sodelavec";
treeimport.ParentIdColumnName = "id_mentor";

// create vertices as rectangles shapes
NBasicShapesFactory shapesFactory = new NBasicShapesFactory();
treeimport.VertexShapesFactory = shapesFactory;
treeimport.VertexShapesName = BasicShapes.Rectangle.ToString();

// use layered tree layout
NLayeredTreeLayout layout = new NLayeredTreeLayout();
layout.Direction = LayoutDirection.LeftToRight;
layout.OrthogonalEdgeRouting = true;
layout.LayerAlignment = RelativeAlignment.Near;
treeimport.Layout = layout;

// subscribe for the vertex imported event,
// which is raised when a shape was created for a data source record
treeimport.VertexImported += new ShapeImportedDelegate(OnVertexImported);
treeimport.ImportFailed += new EventHandler(treeimport_ImportFailed);
// import
treeimport.Import();
NDrawingView1.Document.SizeToContent();
}

void treeimport_ImportFailed(object sender, EventArgs e)
{

throw new NotImplementedException();
}
private void OnVertexImported(NDataSourceImporter importer, NShape shape, INDataRecord dataRecord)
{
// display the page title in the shape
object text = dataRecord.GetColumnValue("ime");
if (text == null)
{
shape.Text = "Title not specified";
}
else
{
shape.Text = text.ToString();
}
shape.SizeToText(new NMarginsF(10));
// make the URL a tooltip of the shape
object url = dataRecord.GetColumnValue("priimek");
if (url == null || url.ToString().Length == 0)
{
shape.Style.InteractivityStyle = new NInteractivityStyle("URL not specified");
}
else
{
shape.Style.InteractivityStyle = new NInteractivityStyle(url.ToString());
}
}

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search