0

I'm doing some queries in the database and must return through the Json, but I can not hit the fomato. I'm doing the following:

var dataResult = new List<List<Object>>();

I query the database and and add below

dataResult.Add(new List<object>(new object[] { "rRod:" + rod, "rKmI:" + vlrkmI, "rKmF:" + vlrkmF, "rExt:" + ext, "rSol:" + sol }));

To assemble the table use

function (data) {
    $("#divResult").empty();

    //Adicionar a tabela na div
    table = "<fieldset style='height:50px '><legend>Resultado da Matriz</legend><table id='tableResult'><tr><th>Rod</th>";
    table += "<th>kmI</th><th>kmF</th><th>Ext</th><th>Sol</th></fieldset>"
    $("#divResult").append(table);

    $(eval(data)).each(function (data) {
    $("#tableResult").append(
        "<tr><td>" + this.rRod+ "</td>" + 
        "<td>" + this.rKmI + "</td>" + 
        "<td>" + this.rKmF + "</td>"
        "<td>" + this.rExt + "</td>" +
        "<td>" + this.rSol + "</td></tr>");
});

But not this genrando the table with values​​.

2
  • Sorry I don't know what you are doing. Could you read this and try again? msmvps.com/blogs/jon_skeet/archive/2010/08/29/… Commented May 27, 2014 at 13:16
  • What I'm wondering is how should be the format of the json output to generate a table. Commented May 27, 2014 at 13:22

1 Answer 1

1

What I would suggest you to do is instead of doing a list of object create a class with those properties something like this :

var dataResult = new List<List<sometypewhichhasallofthosejsobproperties>>();

Now from the mvc action just simply return jsonresult of the dataresult. This should format your data to json nicely and you should be able to work with it in jquery easily.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.