forum

Home / DeveloperSection / Forums / How to insert an List of string array into a table rows in Javascript

How to insert an List of string array into a table rows in Javascript

Anonymous User 2330 17-Dec-2013

Hi I have a MVC project and I am calling a POST to get data from server-side which works great!

I have a bootstrap css table to which I want to bind all the data in the call back function for POST.

Below is my code snippet:

JS:

dataButton.on("click", function GetTRS() {
        var objectID = updateFeature.attributes.OBJECTID;
        var Direction = updateFeature.attributes.DIR;
        var Township = updateFeature.attributes.TWNSHP;
        var Range = updateFeature.attributes.RNG;
        var Section = updateFeature.attributes.SECTION_;
        $.post("/Home/Index", { "T": Township, "R": Range, "S": Section }, function (data) {}, 'json');
    });

HTML

div class="container">
<table class="Computed CIR table table-bordered">
    <thead>
        <tr>
            <th style="text-align: center"><b>Crop</b></th>
            <th style="text-align: center"><b>ET (inches)</b></th>
            <th style="text-align: center"><b>Eff.Rain (inches)</b></th>
            <th style="text-align: center"><b>CIR (inches)</b></th>
            <th style="text-align: center"><b>Recharge (inches)</b></th>
        </tr>
    </thead>
    <tbody data-bind="foreach: data">
        <tr>
            <td style="text-align: center" data-bind="text: opCropName"></td>
            <td style="text-align: center" data-bind="text: opET"></td>
            <td style="text-align: center" data-bind="text: opEffRain"></td>
            <td style="text-align: center" data-bind="text: opCIR"></td>
            <td style="text-align: center" data-bind="text: opRecharge"></td>
        </tr>
    </tbody>
</table>

The data returned from post is a LIST of string arrays with each array having the five data types I am trying to bind to the cells in each row of the table.

Thank you in advance!!


Updated on 17-Dec-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By