show Select sql with extJS in .net

0

someone can help me I am using extJS but I can not show the data of a table in my database in a MVC grid use of .Net, this error marks me

app.js

    var store = Ext.create('Ext.data.JsonStore', {


    storeId: 'myData',
    reader: new Ext.data.JsonReader({
        fields: [
            { name: 'EmpleadoId', type: 'int' },
            { name: 'NombreEmpleado', type: 'string' },
            { name: 'DirectorId', type: 'int' }]
    }),

    proxy: {
        type: 'json',
        url: 'TestController/writeRecord'
    }

});
this.grid = Ext.create('Ext.grid.Panel', {
    title: 'GridView App',
    url: 'TestController/writeRecord',
    //store: store,
    store: Ext.data.StoreManager.lookup('myData'),
    columns: [
        {
            header: 'EmpleadoId', width: 100,
            sortable: true, dataIndex: 'EmpleadoId'
        },
        {
            header: 'NombreEmpleado', width: 100,
            sortable: true, dataIndex: 'NombreEmpleado'
        },
        {
            header: 'DirectorId', width: 100,
            sortable: true, dataIndex: 'DirectorId'
        }
    ],
    stripeRows: true,
    //height:250,
    width: 800,
    renderTo: Ext.getBody()
});

Controller

public class TestController : Controller
    {
        // GET: Test
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult writeRecord()
        {

            Response.Write("Survey Completed!");
            SqlConnection conn = new SqlConnection("Server=PC;Database=TestPersona;Trusted_Connection=yes;");


            string sqlquery = "SELECT EmpleadoId,NombreEmpleado,DirectorId FROM Empleados";
            SqlDataAdapter cmd = new SqlDataAdapter(sqlquery, conn);

            DataSet myData = new DataSet();
            cmd.Fill(myData, "Empleados");


            conn.Open();
            conn.Close();

            return Json(myData, JsonRequestBehavior.AllowGet);

        }


    }

View

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/Content/charts-all.css" rel="stylesheet" />
    <script src="~/Scripts/ext-all.js"></script>
    <script src="~/Scripts/app.js"></script>
</head>
<body>
    <div> 
    </div>
</body>
</html>
    
asked by Ivxn 19.07.2018 в 21:16
source

0 answers