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

[Solved] Custom ajax edit button

0 Answers 50 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.
Ryan Black
Top achievements
Rank 1
Ryan Black asked on 22 Apr 2011, 06:57 PM
I am trying to create my own edit button and am having a very hard time attempting to get the data to populate inside the popup.  The window opens and is completely blank.  The data object has all the needed json data.

Thanks
Ryan

@{ Html.Telerik().Window()
    .Name("EditWindow")
    .Title("Edit Window")
    .Buttons(b => b.Close())
    .Visible(false)
    .Modal(true)
    .Width(600)
    .Height(600)
    .Draggable(true)
    .Resizable()
    .Render();
    }
 
        @{ Html.Telerik().Grid(Model)
        .Name("Grid")
        .DataKeys(dataKeys => dataKeys.Add(c => c.Id))
        .Columns(columns =>
        {
            columns.Bound(o => o.PartNumber).Width(100);
            columns.Template(@<text>
                <input type='button' value='Edit' onclick="updateRecord('@item.Id')" />
                <input type='button' value='Delete' onclick="deleteRecord('@item.Id')" />
            </text>);
        })
        .Groupable()
        .Sortable()
        .Pageable()
        .Filterable()
        .Render();
    }
 
 
        @section footer {
    <script>
 
        function updateRecord(id) {
 
            var url = '@Url.Action("CustomEdit", "Gage")';
            $.post(url, { id: id }, function (data) {
                var window = $('#EditWindow').data('tWindow');
                window.content(data);
                window.center().open();
            });
        }
 
        function deleteRecord(id) {
            var url = '@Url.Action("CustomDelete", "Gage")';
            $.post(url, { id: id });
        }
 
    </script>
 
}
Tags
Grid
Asked by
Ryan Black
Top achievements
Rank 1
Share this question
or