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

Inline insert

2 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mitchell
Top achievements
Rank 1
Mitchell asked on 12 Nov 2010, 08:06 PM
I have have a mvc grid that is very similar to the AJAX editing demo except I don't have an edit button.  The issue that I am having is when I click the insert new record button, I do not get the insert and cancel buttons.  The delete button stays in this mode and I never see the other buttons.  I get the insert and cancel buttons if I use InForm or PopUp.

I will post my code if necessary but I was wondering if anyone else has had this issue.  I have seen a few similar cases here on the forums but I have not seen a solution for my exacpt problem.

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 15 Nov 2010, 08:52 AM
Hello Mitchell,

Currently the edit command serves as a placeholder for save and cancel. It is ambiguous where to render the Insert and Cancel buttons if the Edit command is not present. For example the grid may have more than one command column.

As a workaround you can use the OnEdit event and add the buttons in the last cell:

<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .ToolBar(tools => tools.Insert())
        .DataKeys(keys => keys.Add(c => c.ID))
        .Columns(columns =>
        {
            columns.Bound(c => c.Name);
            columns.Command(c => c.Delete()).Width(200);
        })
        .DataBinding(dataBinding => dataBinding.Ajax().Insert("foo", "bar").Delete("foo", "bar"))
        .ClientEvents(e => e.OnEdit("onEdit"))
%>
<script type="text/javascript">
    function onEdit(e) {
        if (e.mode == 'insert') {
            $(e.form).find('td:last')
                     .append('<a href="#" class="t-grid-action t-button t-state-default t-grid-insert">Insert</a>')
                     .append('<a href="#" class="t-grid-action t-button t-state-default t-grid-cancel">Cancel</a>')
                     .find('.t-grid-delete')
                     .remove();
        }
    }   
</script>
</asp:Content>

Regards,

Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mitchell
Top achievements
Rank 1
answered on 15 Nov 2010, 06:42 PM
Thank you Atanas Korchev.  That worked like a charm.
Tags
Grid
Asked by
Mitchell
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Mitchell
Top achievements
Rank 1
Share this question
or