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

[Solved] binding to json issue

0 Answers 89 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.
Charley
Top achievements
Rank 1
Charley asked on 30 Jun 2011, 07:33 PM
I followed examples to the tea as far as I think.  Please take a look at my code and tell me what is incorrect.  It does not seem to be even calling the JavaScript.  This was setup to originally get information from the server and worked I reconfigured it to except JSON instead.  Thanks for the replies.

<h2>Index</h2>
<script type="text/javascript" src="Scripts/jquery-1.5.1.js"></script>
<div class="t-web20">
@(
    Html.Telerik().Grid<IMRS.Model.WhyMadeCode>("whyMadeCode").Name("whyMadeCode")
        .DataKeys(k => k.Add(o => o.ID))
        .Columns(c =>
        {
            c.Bound(o => o.WhyMadeNumber).ReadOnly();
            c.Bound(o => o.Description).ReadOnly();
        })
        .ClientEvents(events => events
            .OnDataBinding("onDataBinding")
        )
        .Sortable()
)
</div>
<input type="button" id="getCustomers" value="Get Customers" />
         <ul id="customersList">
         </ul>
<script type="text/javascript">
    function onDataBinding(e) {
        var grid = $(this).data('tGrid');
 
        $('.t-status .t-icon', grid.element).addClass('t-loading');
        // call the twitter search api
        $.ajax({
            contentType: 'application/json; charset=utf-8',
            type: 'GET',
            dataType: 'jsonp',
            error: function (xhr, status) {
                alert(status);
            },
            data: { //alert()
                //q: $('#searchText').val()
            },
            success: function (result) {
                alert(result.results);
                grid.dataBind(result.results);
                $('.t-status .t-icon', grid.element).removeClass('t-loading');
            }
        });
    }
</script>
Tags
Grid
Asked by
Charley
Top achievements
Rank 1
Share this question
or