Display multiple JSON values in single GridView column using jQuery

Last Reply one year ago By mukesh1

Posted one year ago

i want data for databind in gridview using jquery in row wise only, no need of columnswise

means only one column there, but want to data according to row

<script type="text/javascript">
    $(function () {
        $.ajax({
            type: "POST",
            url: "Default.aspx/GetChatDatas",
            data: {},
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccess,
            error: function (r) { alert(r.responseText); }
        });
        return false;
    });
    function OnSuccess(response) {
        var chatDatas = response.d;
        var row = $("[id*=grdchat] tr:last-child").clone(true);
        $("[id*=grdchat] tr").not($("[id*=grdchat] tr:first-child")).remove();
        for (var i = 0; i < chatDatas.length; i++) {
            for (var j = 0; j < chatDatas[i].length; j++) {
                $("td", row).eq(j).html(chatDatas[i][j]);
            }
            row.removeClass();
            row.addClass(chatDatas[i][chatDatas[i].length - 1]);
            $("[id*=grdchat]").append(row);
            row = $("[id*=grdchat] tr:last-child").clone(true);
        }
    }
</script>

in this code we are adding value to all column, if i wnat to add only row and with insertion of html in row can add any column there.

for (var i = 0; i < chatDatas.length; i++) {
    for (var j = 0; j < chatDatas[i].length; j++) {
        $("td", row).eq(j).html(chatDatas[i][j]);
    }
}

here how to add value in row???

Posted one year ago

i have 5 column which contains value,

but want to add value according to row like 

for (var i = 1; i < chatDatas.length; i++) {
    $("td", row).eq(j).html(chatDatas[i][1] +"....."+chatDatas[i][2] '<br/><br/>');
}

i don't understand what i will type here for row only

i changed

$("td", row).eq(j).html
to
$("td", row).eq(0).html

then it's working.