binding json to a data table, but it doesn't keep happening.

binding json to a data table, but it doesn't keep happening.

Lee SongSeopLee SongSeop Posts: 4Questions: 0Answers: 0

Json files are sent, but it does not seem to binding to the datatable.Help me.

controller

        [HttpGet]
        public ActionResult ProjectList()
        {
            using (WsProxy ws = new WsProxy())
            {
                dt = ws.DoSyncWork("WebView", "GetProjectList", "GetProjectList", true, "", "");
                foreach (DataRow row in dt.Rows)
                {

                    lstModel.Add(new ProjectModels
                    {
                        SKND_GRP =row["SKND_GRP"].ToString(),
                        PROJ_NO = row["PROJ_NO"].ToString(),
                        SERS_NO = row["SERS_NO"].ToString(),
                        CLS_1 = row["CLS_1"].ToString(),
                        PROJ_DSC = row["PROJ_DSC"].ToString(),
                        OWN_AB = row["OWN_AB"].ToString(),
                        SKND = row["SKND"].ToString(),
                        SC_DT = row["SC_DT"].ToString(),
                        KL_DT = row["KL_DT"].ToString(),
                        LC_DT = row["LC_DT"].ToString(),
                        DL_DT = row["DL_DT"].ToString(),
                    });
                };
            }

            return Json(lstModel , JsonRequestBehavior.AllowGet);
        }

view

@{

    ViewBag.Title = "Project";
}

<head>
    <title></title>

    <script src="~/Scripts/jquery-3.3.1.js"></script>
    <link href="~/Scripts/DataTables/DataTables-1.10.18/css/dataTables.bootstrap.css" rel="stylesheet" />
    <link href="~/Scripts/DataTables/DataTables-1.10.18/css/dataTables.jqueryui.css" rel="stylesheet" />

    <script src="~/Scripts/DataTables/DataTables-1.10.18/js/jquery.dataTables.js"></script>

    <script type="text/javascript" language="javascript">
        $(document).ready(function () {

            $.noConflict();
           var table= $('#Project_table').DataTable({
                "ajax": {
                    "type": "GET",
                    "contenttype": "application/json; charset=utf-8",
                    "datatype": "json",
                    "url": '/Sample/ProjectList',
                    
                   "dataSrc":""
                },
               
                "columns": [
                    {"data":"SKND_GRP"},
                    { "data": "PROJ_NO" },
                    { "data": "SERS_NO" },
                    { "data": "CLS_1" },
                    { "data": "PROJ_DSC" },
                    { "data": "OWN_AB" },
                    { "data": "SKND" },
                    { "data": "SC_DT" },
                    { "data": "KL_DT" },
                    { "data": "LC_DT" },
                    { "data": "DL_DT" },
                ]
            });


        });

        //    //$.noConflict();
        //    //$("#Projcet_table").DataTable();


        //});

    </script><?xml version="1.0" encoding="utf-8" ?>



    </head>
       
    <h2>Project</h2>

<body>
    <form> 
        <table class="display" id="Projcet_table" style="width:100%">
            <thead>
                    <tr>
                        <th>SKND_GRP</th>
                        <th>PROJ_NO</th>
                        <th>SERS_NO</th>
                        <th>CLS_1</th>
                        <th>PROJ_DSC</th>
                        <th>OWN_AB</th>
                        <th>SKND</th>
                        <th>S/C</th>
                        <th>K/L</th>
                        <th>L/C</th>
                        <th>D/L</th>
                    </tr>
                </thead>


        </table>
    </form>

</body>
        

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @Lee SongSeop ,

    There really isn't much information here to help, I'm afraid - you haven't said if the data is transferred but not loading, or if there's errors on the server side or the client.

    We're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Is this a duplicate of this thread? You said it was solved on that last one...

  • Lee SongSeopLee SongSeop Posts: 4Questions: 0Answers: 0

    The previous one was to bring the db data into the html body and apply it.This is an application of db data to ajax in json format.And I applied it several times using the test case you told me about, and it seems to be working. Maybe there was an error because the typos were stuck in the middle...Thanks anyway!

This discussion has been closed.