Ahmed_39 0 Newbie Poster

**Hi,

i have two tables PTDatas and ClinicCodes and the are joind in (Clinic_Code_ID) now i try to view Table PTDatas in my jtable but i got err

An error occured while communicating to the server.

if i delete the join between tables i can view it ??!!, so how can i view it and still have th relations between two tables ?

Jtable JS:**

/// <reference path="../jtable/jquery.jtable.min.js" />



$(document).ready(function () {
    $("#TermsContainer").jtable({
        title: "Display Terms ",
        selecting: true,
        footer: true,
        actions: {
            listAction: "/PTDatas/List",
            createAction: "/Home/Create",
            updateAction: "/Home/Edit"
        },
        fields: {
            PT_Name: {
                title: 'PT_Name',
                width: '15%',
            }
        },
    });
    $("#TermsContainer").jtable("load");
});

Index Html:

<div id="TermsContainer"></div>


@section scripts{

    <script src="~/Scripts/jquery-2.1.1.min.js"></script>
    <script src="~/Scripts/jquery-ui-1.10.4.min.js"></script>
    <link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />

    <link href="~/Scripts/jtable/themes/metro/green/jtable.min.css" rel="stylesheet" />
    <script src="~/Scripts/jtable/jquery.jtable.min.js"></script>
    <script src="~/Scripts/App/TermsJTable.js"></script>

}

Controller Code:

private Model1 db = new Model1();

        public ActionResult List()
        {
            try
            {
                var model = db.PTDatas;
                return Json(new { Result = "OK", Records = model });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Mssage = ex.Message });
            }
        }

i try :

     public ActionResult List()
        {
            try
            {
                var model = db.PTDatas.Include(p => p.ClinicCodes);
                return Json(new { Result = "OK", Records = model });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Mssage = ex.Message });
            }
        }

but not working too it works only when i delete the join between the two tables - i want to display PTDatas data in my Jtable but when i run i don't get any data in Jtable, if i delete join between PTDatas and ClinicCodes i can get PTDatas in Jtable, so how can i get PTDatas in my Jtable when it joined to ClinicCodes ???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.