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

[Solved] Ajax Grid loading on first view.

2 Answers 176 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.
Carlos Adolfo Ortiz
Top achievements
Rank 1
Carlos Adolfo Ortiz asked on 23 Jul 2010, 12:11 AM
Hi you all pal. Happy coding.

I have an issue that is making me mad.
I have put a Grid using Ajax binding and client template for user defined checkboxes and links for ids. But when I first see page it is not rendered as such, only some ids, I have to push on the refresh button and so it appears the checkboxes and links I want. The examples are doing this stuff, but I have not found how.

Can you help me on this.
I am now using version 2010.2.713 of components, I thought the Beta version should have fixed it, but not.

Well. I am editing this post so you can help me. I am attaching screenshots.

The first file Cat001.png is the initial rendering when I first load the Controller View.
I am using Ajax Grid mode.
And I need what is shown in Cat002.png.
Can anybody help me with this problem?

I also take this opportunity to help me out with column width.
The code snippet to render what is shown in Cat001.png and Cat002.png follows:

>
 <%: Html.Telerik().Grid<CategoryInfo>(Model)
        .Name("CList")
        .Columns(columns => {
            columns.Bound(o => o.CategoryId)
                   .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= CategoryId #>' />")
                   .Title("")
                   .Width(10)
                   .HtmlAttributes(new { style = "text-align:center" });
            columns.Bound(o => o.CategoryId).Title("Cat.").Width(10).ClientTemplate("<a href='"+Url.Action("Edit""Category")+"/<#= CategoryId #>'>" + ViewRes.CategoryMessages.EditLink + "</a>");
            columns.Bound(o => o.Name).Title("Nombre").Width(100);
            columns.Bound(o => o.ShortName).Title("Nombre Abr.").Width(100);
            columns.Bound(o => o.CategoryTypeDescription).Title("Tipo Categoría").Width(100);
        })
        .DataBinding(dataBinding => {
            dataBinding.Server().Select("Index""Category");
            dataBinding.Ajax().Select("IndexAjax""Category");
        })            
        .Scrollable(scrolling => scrolling.Enabled(true))
        .Pageable(pager => pager.PageSize(10))
        .Sortable()
        .Footer(true)
    %>


2 Answers, 1 is accepted

Sort by
0
murali
Top achievements
Rank 1
answered on 06 Aug 2010, 04:31 PM
I have the same issue, my workaround is to call a javascript function which would refresh the grid either on data bound or something.

function refresh_grid() {
            var grid = $('#CList').data('tGrid');
            // rebind the related grid
            grid.rebind({
                var1: $('#_var1_id').val(), // input parameters for grid.
                var2: $('#_var2_id').val()
            });
        }

mk
0
Andreea
Top achievements
Rank 1
answered on 08 Sep 2010, 04:41 PM
Hi Carlos, 

I had the same problem and as a workaround I used both ClientTemplate and Template:

columns.Bound(o => o.OrderID).Template(o =>
            {
                %>
                    <input name="checkedRecords" type="checkbox" value="<%= o.OrderID %>" title="checkedRecords"
                    <% if (checkedRecords.Contains(o.OrderID)) {
                         
                        %> checked="checked" <%
                      } %>
                   />
                <%
            });
                   .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= OrderID #>' />")
                   .Title("Check")
                   .Width(50)
                   .HtmlAttributes(new { style = "text-align:center" })

Good Luck!
Tags
Grid
Asked by
Carlos Adolfo Ortiz
Top achievements
Rank 1
Answers by
murali
Top achievements
Rank 1
Andreea
Top achievements
Rank 1
Share this question
or