This is a migrated thread and some comments may be shown as answers.

this constraint cannot be enabled as not all values have corresponding parent values

1 Answer 272 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Rizwan Ansari
Top achievements
Rank 1
Rizwan Ansari asked on 28 Oct 2014, 05:36 AM
Dear Support,

I am getting above error when radmenu is getting its datasource dynamically. please check the below code.

Create PROCEDURE [dbo].[HGetSubMenu]
(
@categoryid int
)
AS
begin
DECLARE @level int
  
    /* Creating temporary table for tree storage*/
    CREATE TABLE #temp_tree
    (
        level int,
        id int NOT NULL PRIMARY KEY,
        ptr int,
        f1 char(20)
    )
  
    INSERT #temp_tree (level, id, ptr, f1)
    SELECT 0, categoryid, parentid, categoryname FROM HCategroyNew WHERE categoryid = @categoryid
    SELECT @level = 0
  
    WHILE 1 = 1
    BEGIN
        INSERT #temp_tree (level, id, ptr, f1)
        SELECT
            @level + 1, HCategroyNew.categoryid, HCategroyNew.parentid, HCategroyNew.categoryname  
        FROM
            HCategroyNew, #temp_tree tt
        WHERE
                HCategroyNew.parentid = tt.id
            AND tt.level = @level
  
        IF @@rowcount = 0 BREAK
         
        SELECT @level = @level + 1
    END
  
    SELECT id, ptr, f1,level
    FROM #temp_tree
    DROP TABLE #temp_Tree
end

Dataset Table Structure
id  ptr f1                     level
3   1   Bedrooms                0
13  3   Classical               1
14  3   Modern                  1
15  3   Contemporary            1
16  3   Transitional            1
17  3   Arte Deco               1

Radmenu Binding.
RadMenu1.DataSource = ds.Tables[0];
             
            RadMenu1.Flow = ItemFlow.Horizontal;
            RadMenu1.DataTextField = "f1";
            RadMenu1.DataFieldID = "ptr";
            RadMenu1.DataValueField = "id";
            RadMenu1.DataFieldParentID = "level";
            RadMenu1.DataBind();

Please help me urgent.

Thanks
Rizwan

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 30 Oct 2014, 03:06 PM
Hi Rizwan,

The tree expects that you will have at least one root item. For example:
id  ptr f1                     level
3   NULL   Bedrooms                0
13  3   Classical               1
14  3   Modern                  1
15  3   Contemporary            1
16  3   Transitional            1
17  3   Arte Deco               1

At the moment the first item has parent item with ID #1 and this parent is not among the returned rows. 

Regards,
Hristo Valyavicharski
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Menu
Asked by
Rizwan Ansari
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or