0

I'm new to MVC, and I was trying to create a page to list items, and I can Add/Edit items in this list.

I used telerik MVC grid to show the list of items, what I want now is to know is there a way to customize how the add/edit popup of the telerik grid.

The reason is that I need to hide some fields, and add some other lookups.

Thanks in advance.

2 Answers 2

2

You can create a custom Editor Template. In the folder EditorTemplates under Views/Shared, add a view that has the name of your model. When you use pop up editing, it will use the template you defined.

Telerik has an example project demonstrating how this is done: Custom PopUp Editor Form.

Here is the code for an Editor Template I made for a project where my model was Tasks:

@model Whiteboard.Models.Tasks

<fieldset>
    <legend>Tasks</legend>

    @Html.HiddenFor(c => c.TID)

    <div>
    <p>
        @Html.LabelFor(w => w.Task):<br />
        @Html.TextBoxFor(c => c.Task, new { style = "width: 375px;" })
    </p>
    </div>
    <div>
    <p>
        @Html.LabelFor(w => w.WDate):<br />
        @Html.EditorFor(c => c.WDate)
    </p>
    </div>
    <div>
    <p>
        @Html.LabelFor(w => w.Description):<br />
        @Html.TextAreaFor(c => c.Description, new { cols = "45", rows = "15", @class = "ext_TextArea" })
    </p>
    </div>
    <div>
    <p>
        @Html.LabelFor(w => w.Notes):<br />
        @Html.TextAreaFor(c => c.Notes, new { cols = "45", rows = "5", @class = "ext_TextArea" })
    </p>
    </div>
</fieldset>
Sign up to request clarification or add additional context in comments.

4 Comments

it works , but when I tried to save the data it did not work and I can see this error in firebug "a(this).data("tTextBox") is undefined "; am I missing something?
My guess is there is a problem with the mapping between the textbox and your model. Make sure you have the correct field name in the editor template. Beyond that, I'm not sure.
what I'm sure of is that is something related to telerik scripts, and that I do not have any field with that name "tTextBox"
also I noticed that when I added a datepicker I can't open the selection window!!
1

I wrote a detailed series on a master/detail AJAX-driven Telerik MVC grid, which makes use of an editor template in the detail grid's editor pop-up, and also hides some columns (getting around some issues with that). I discuss this in part 3, and you can download the full sample app. Hopefully that can help a bit.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.