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

No results in json from remote data source

1 Answer 185 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Michael Harry
Top achievements
Rank 1
Michael Harry asked on 18 Apr 2012, 02:28 AM

hi all, new to kendo, new to json. Can't seem to get any data into a kendo.data.DataSource. Am using the new 2012 q1 mobile release and ASP.NET MVC 3. Here's my code:

js:

    // create a template using the definition on the application page (the .cshtml file)
    var templateFundingSources = kendo.template($("#template-funding-sources").html());
 
    dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "/Home/GetCardFundings"// the remove service url
                dataType: "json"// JSONP (JSON with padding) is required for cross-domain AJAX
 
                data: {
                    //additional parameters sent to the remote service
                    _cardId: cardID
                }
            }
        },
 
 
        schema: {
            data: "cardFunding",
            model: {
                id: "CardID",
                fields: {
                    CardID: {
                        type: "number",
                        nullable: false
                    },
                    RemainingBalance: {
                        type: "number"
                    }
                }
            }
        },
 
 
        change: function () { // subscribe to the CHANGE event of the data source
            $("#listview-card-fundings").html(kendo.render(templateFundingSources, this.view()));
        }
    });
 
 
    dataSource.read();

    //test data source to see it's defined     dataSource.add({ cardID: 4, remainingBalance: 34 });

and MVC code:

public JsonResult GetCardFundings(int _cardId)
        {
            List<CardFunding> cfs = new List<CardFunding>();
 
            CardFunding cf = new CardFunding();
            cf.CardID = 1;
            cf.RemainingBalance = 3;
            cfs.Add(cf);
 
            CardFunding cf1 = new CardFunding();
            cf1.CardID = 1;
            cf1.RemainingBalance = 3;
            cfs.Add(cf);
            return Json(cfs, JsonRequestBehavior.AllowGet);
        }

The server-side code gets called and returned, and no execptions are tripped anywhere there or in the .js.
Any help greatly appreciated.

Kendo team: Awesome job on the project. Looking forward to mastering your framework.

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 19 Apr 2012, 11:55 AM
Hello Michael,

I'm afraid that it is not clear what may be the caused for the behavior you have described. Therefore, could you please open a support ticket and provide a small runnable sample in which this issue can be observed locally. Meanwhile, you may take a look at this sample project which demonstrates DataSource populated through ASP.NET MVC action.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Michael Harry
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or