This question is locked. New answers and comments are not allowed.
Hi all,
I am using the grid's Insert command in the toolbar to add a new row to the grid to add new stuff in my database.
Based on the Ajax Editing demo on Telerik's web page, I've been able to perform this with success but, it adds the new row at the very top of the grid's items and, upon insertion, it rebinds the grid and displays the new item at the end in the order it was inserted.
From a user standpoint, it's not really acceptable as users might start to search for what they entered on large volume of data.
So my first question is, how can I make the new row be inserted at the very bottom of the grid's items?
there is no paging, sorting, or anything like that here so, it eases a bit the pain it would bring otherwise.
Another issue I have is the new row look and feel when I access the page for the first time only. It's not aligned with the column headers.
As soon as I insert a new item, it aligns correctly and stays like that for any subsequent inserts.
Here's the Grid's code I have in my view
:
Thanks for the help!
I am using the grid's Insert command in the toolbar to add a new row to the grid to add new stuff in my database.
Based on the Ajax Editing demo on Telerik's web page, I've been able to perform this with success but, it adds the new row at the very top of the grid's items and, upon insertion, it rebinds the grid and displays the new item at the end in the order it was inserted.
From a user standpoint, it's not really acceptable as users might start to search for what they entered on large volume of data.
So my first question is, how can I make the new row be inserted at the very bottom of the grid's items?
there is no paging, sorting, or anything like that here so, it eases a bit the pain it would bring otherwise.
Another issue I have is the new row look and feel when I access the page for the first time only. It's not aligned with the column headers.
As soon as I insert a new item, it aligns correctly and stays like that for any subsequent inserts.
Here's the Grid's code I have in my view
| <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MasterPageWithMenu.master" |
| Inherits="System.Web.Mvc.ViewPage<IList<SimpleOrderDto>>" %> |
| <asp:Content ID="Content2" ContentPlaceHolderID="cphHead" runat="server"> |
| <% |
| Html.Telerik().ScriptRegistrar().Scripts(s => s.Add("~/Scripts/Order.js")); |
| %> |
| <style type="text/css"> |
| .field-validation-error |
| { |
| position: absolute; |
| display: block; |
| } |
| * html .field-validation-error |
| { |
| position: relative; |
| } |
| * + html .field-validation-error |
| { |
| position: relative; |
| } |
| .field-validation-error span |
| { |
| position: absolute; |
| white-space: nowrap; |
| color: red; |
| padding: 17px 5px 3px; |
| background: transparent url('<%= Url.Content("~/Content/Common/validation-error-message.png") %>') no-repeat 0 0; |
| } |
| </style> |
| </asp:Content> |
| <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> |
| <% |
| Html.Telerik().Grid<SimpleOrderDto>(Model) |
| .Name("Grid") |
| .DataKeys(keys => { keys.Add(c => c.Sku); }) |
| .ToolBar(commands => commands.Insert() |
| .DataBinding(dataBinding => |
| { |
| dataBinding.Server() |
| .Select("Index", "Order"); |
| dataBinding.Ajax() |
| .Insert("_AddNewOrder", "Order") |
| .Delete("_DeleteOrder", "Order") |
| .Select("_Index", "Order"); |
| }) |
| .Columns(columns => |
| { |
| columns.Bound(c => c.Sku).Width("10%").Title(ViewRes.Order_FastAdd.Sku); |
| columns.Bound(c => c.Qty).Width("5%").Title(ViewRes.Order_FastAdd.Qty); |
| columns.Bound(c => c.OldSku).Width("15%").Title(ViewRes.Order_FastAdd.OldSku).ReadOnly(true).HtmlAttributes(new { id = "OldSku" }); |
| columns.Bound(c => c.Description).Width("20%").Title(ViewRes.Order_FastAdd.Description).ReadOnly(true).HtmlAttributes(new { id = "Description" }); |
| columns.Bound(c => c.Message).Width("15%").Title(ViewRes.Order_FastAdd.Message).ReadOnly(true).HtmlAttributes(new { id = "Message" }); |
| columns.Bound(c => c.AvailQty).Width("15%").Title(ViewRes.Order_FastAdd.AvailQty).ReadOnly(true).HtmlAttributes(new { id = "AvailQty" }); |
| columns.Command(commands => |
| { |
| commands.Delete(); |
| }).Width("10%").Title(ViewRes.Order_FastAdd.Delete); |
| }) |
| .Render(); |
| %> |
| <% |
| Html.Telerik().ScriptRegistrar().OnDocumentReady(() => |
| { |
| %> |
| $('.insert-button').click(function(e) { e.preventDefault(); $('#Grid').data('tGrid').createRow(); |
| }); |
| <% |
| }); |
| %> |
| </asp:Content> |
Thanks for the help!