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

more trouble

1 Answer 2108 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Iron
Veteran
Iron
Ed asked on 10 Feb 2021, 03:05 PM

Hi,

I keep getting the error show below:

 EditForm requires either a Model parameter, or an EditContext parameter, please provide one of these.

It happen when I click on a NON-root item to edit. 

Any ideas?

<TelerikWindow Visible="@ShowComments" Modal="true" Width="55vw" Height="60vh">
    <WindowTitle>
        @CommentDlgTitle
    </WindowTitle>
    <WindowActions>
        <WindowAction Name="Close" OnClick="@OnCloseFindComments"></WindowAction>
    </WindowActions>
    <WindowContent>
        
            <div class="form-row justify-content-end ml-2">
                <div class="col overflow-y:auto">
                    <br />
                    <TelerikTreeList Data="@CommentsData"
                                     ItemsField="@(nameof(CommentItem.Children))"
                                     @ref="CommenterTL"
                                     Pageable="true"
                                     Sortable="true"
                                     FilterMode="@TreeListFilterMode.FilterMenu"
                                     SelectionMode="@TreeListSelectionMode.Single"
                                     Resizable="true"
                                     Reorderable="true"
                                     EditMode="@TreeListEditMode.Popup"
                                     OnEdit="@EditComment"
                                     OnCreate="@CreateComment"
                                     OnUpdate="@UpdateComment"
                                     OnDelete="@DeleteComment">
                        @*OnUpdate="@UpdateItem"*@
                        <TreeListToolBar>
                            <TreeListCommandButton Command="Add" Icon="add">Add</TreeListCommandButton>
                        </TreeListToolBar>
                        <TreeListColumns>
                            <TreeListColumn Title="Subject" Width="250px" Field="FindComment.Subject" Editable="true" Expandable="true">
                                <EditorTemplate Context="ctx">
                                    @{
                                        var item = (ctx as CommentItem);
 
                                        //Enabled = "@(item.FindComment.ParentCommentId == null)"
                                        if (item.FindComment == null)
                                        {
                                            item.FindComment = new FindComment();
                                        }
                                        item.FindComment.Subject = SelectedComment.FindComment.Subject;
                                        //SelectedComment = item;
                                        <TelerikTextBox @bind-Value="@SelectedComment.FindComment.Subject">
                                        </TelerikTextBox>
                                    }
                                </EditorTemplate>
                            </TreeListColumn>
 
                            <TreeListColumn Title="Comment" Resizable="false" Editable="true" Field="FindComment.Comment" Width="350px">
                                <EditorTemplate Context="ctx1">
                                    @{
                                        var item = (ctx1 as CommentItem);
                                        if (item.FindComment == null)
                                            item.FindComment = new FindComment();
                                        SelectedComment = item;
 
                                        //var c = (ctx1 as CommentItem);
                                        //if (c.FindComment == null)
                                        //    c.FindComment = new FindComment();
                                        <TelerikTextArea Width="260px" Class="TelerikTextAreaWidth"
                                                         @bind-Value="@SelectedComment.FindComment.Comment">
                                        </TelerikTextArea>
                                    }
                                </EditorTemplate>
                            </TreeListColumn>
                            <TreeListColumn Title="Name" Width="100px" Field="CommenterName" Context="ctx2" Editable="false">
                            </TreeListColumn>
 
                            <TreeListCommandColumn Width="150px">
 
                                @{
                                    if (SelectedComment != null && SelectedComment.FindComment.Id == appData.AppUser.Id || appData.AppUser.RoleId == (int)ROLE_ENUM.SysAdmin)
                                    {
                                        <TreeListCommandButton Command="Add" OnClick="@OnAddCommentClick" Icon="add"></TreeListCommandButton>
                                        <TreeListCommandButton Command="Edit" OnClick="@OnEditCommentClick" Icon="edit"></TreeListCommandButton>
                                        <TreeListCommandButton Command="Delete" Icon="delete"></TreeListCommandButton>
                                        <TreeListCommandButton Command="Save" Icon="save" ShowInEdit="true"></TreeListCommandButton>
                                        <TreeListCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true"></TreeListCommandButton>
                                    }
                                    else
                                    {
 
                                        <TreeListCommandButton Command="Add" Icon="add"></TreeListCommandButton>
                                        <TreeListCommandButton Command="Save" Icon="save" ShowInEdit="true"></TreeListCommandButton>
                                        <TreeListCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true"></TreeListCommandButton>
                                    }
 
                                }
                            </TreeListCommandColumn>
                        </TreeListColumns>
                    </TelerikTreeList>
 
                </div>
            </div>
            <div class="form-row justify-content-end ">
                <br />
                <TelerikButton Class="mt-2" Icon="cancel" OnClick="@OnCloseFindComments" ButtonType="@Telerik.Blazor.ButtonType.Button">Close</TelerikButton>
            </div>
            <ConfirmWindow ConfirmTitle="Delete comment?"
                           ConfirmText=@("Are you sure you want to delete this comment? All sub comments will also be deleted.")
                           ButtonText="Confirm"
                           OnCancelConfirm="@OnCancelDeleteComment"
                           OnConfirm="@OnConfirmDeleteComment"
                           Icon="warning"
                           Visible="@ShowConfirmDeleteComment">
 
            </ConfirmWindow>
         
</WindowContent>
</TelerikWindow>

1 Answer, 1 is accepted

Sort by
0
Svetoslav Dimitrov
Telerik team
answered on 11 Feb 2021, 12:55 PM

Hello Ed,

This issue seems to stem from the EditForm that comes from the Blazor framework. When you initialize it you should pass either an object to its Model parameter or an EditContext. In the validation Microsoft article, you can see some examples of how to pass both a model and an EditContext. Also, we have an article that shows you how to validate our applicable components.

I hope this helps you move forward with your application.

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TreeList
Asked by
Ed
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Svetoslav Dimitrov
Telerik team
Share this question
or