Results 1 to 2 of 2

Thread: Ask. ASP.NET + ExtJS " store not load the data"

  1. #1
    Sencha User
    Join Date
    Jan 2015
    Posts
    1

    Default Ask. ASP.NET + ExtJS " store not load the data"

    dear all
    please help, I try to display data in Ext.grid.Panel of the Ext.data.Store, where for query I use linq . when i try in the browser data should appear, not shown. is there an error in the script that I created. because there is no error displayed.

    noerror.jpg


    this is my Query Linq

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using BussinessObject.DataContext;
    
    namespace BussinessObject.Core
    {
       
       public  class LoginCore
        {
            public IEnumerable<tbl_Users> getUser()
            {
                using (var entity = new LoginEntities())
                {
                    return entity.tbl_Users.ToList();
                }
            }
            public int getLogin(string usrName, string Password)
            { 
                int value  =0;
                using (var entity = new LoginEntities())
                {                
                    var s = from n in entity.tbl_Users
                            where n.UsrName == (usrName) && n.Password == (Password)
                            select n;
    
                    var t = (from p in entity.tbl_Users
                            where p.UsrName == (usrName) && p.Password == (Password)
                            select p).FirstOrDefault() ;
    
                    getUserID = t.ID_Users .ToString() ;
                    value = s.Count();               
                }
                return value;
            }
            public string  getUserID { get; set; }
        }
    }

    my model

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using BussinessObject.Core;
    namespace HRD.Models
    {
        public class AbsensiModel
        {
            public int id { get; set; }
            public int nik { get; set; }
            public string nama { get; set; }
            public DateTime tanggal { get; set; }
            public DateTime masuk { get; set; }
            public DateTime pulang { get; set; }
            public DateTime masukLembur { get; set; }
            public DateTime pulangLembur { get; set; }
            public int idLokasi { get; set; }
            public string namaLokasi { get; set; }
            public IEnumerable<AbsensiModel> GetlistToday()
            {
                var absen = new AbsensiCore();
                var result = absen.getListAbsensiToday();
                var model = new List<AbsensiModel>();
                foreach (var item in result)
                {
                    var a = new AbsensiModel
                    {   id = item.idTrans,
                        nik = item.nik,
                        nama = item.nama,
                        tanggal = item.tanggal,
                        masuk = item.masuk,
                        pulang = item.pulang,
                        masukLembur = item.masuklembur,
                        pulangLembur = item.pulanglembur,
                        idLokasi = item.idLokasi,
                        namaLokasi = item.Lokasi };
                    model.Add(a);                
                }            
                return model;
            }
        }
    }
    my controller
    Code:
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Dynamic;
    
    
    namespace HRD.Controllers
    {
        public class AbsensiController : Controller
        {
            //
            // GET: /Absensi/
    
            public ActionResult Index()
            {
                return View();
            }
            public ActionResult GetListTodays()
            {
                var model = new AbsensiModel();
                dynamic result = new ExpandoObject();
                result.items = model.GetlistToday();
                result.success = true;
                return Content(JsonConvert.SerializeObject(result, Formatting.Indented, new JavaScriptDateTimeConverter()));   
            }
        }
    }
    extJS file
    Code:
    Ext.ns("master.absensi");
    Ext.define('data.master.absensi', {
        extend: 'Ext.window.Window',
        alias: 'widget.masterPanelAbsensi',
       
        name: 'panelAbsensi',
        id: 'panelAbsensi',
        
        width: 500,
        height: 300,   
        
        initComponent: function () {
            var me = this;
            var datafilter = 0;
            // untuk paging
          //============================= toolbar ==========================
            me.toolbar = Ext.create('Ext.toolbar.Toolbar', {
                width: '100%',
                items: [
                   {
                       xtype: 'button',
                       text: 'Absensi hari ini',//'User Active',                    
                       icon: 'Icon/clipboard16x16.ico',
                       listeners: {
                           click: function () {
                               me.store.load();
                               }
                       }
                   },
                   {
                       xtype: 'button',
                       text: 'Absensi bulan ini',//'User Active',                    
                       icon: 'Icon/clipboard16x16.ico',
                   },
                   {
                       xtype: 'splitbutton',
                       text: 'Absensi Periode',//'User Active',                    
                       icon: 'Icon/clipboard16x16.ico',                   
                       menu: new Ext.menu.Menu(
                           {
                               items: [
                                   {
                                       text: 'Awal Periode',
                                       icon: 'Icon/calendar16x16.ico',
                                       menu: AwalPeriode
                                   },
                                   {
                                       text: 'Akhir Periode',
                                       icon: 'Icon/calendar16x16.ico',
                                       menu: AkhirPeriode
                                   },
                                   {
                                       text: 'Tampilkan Data',
                                       icon: 'Icon/nav_plain_green16x16.ico'
                                   }
                                    
                               ]
                           }
                           )
    
                   }
                  
                ]
            });
            //=================== toolbar ============
            //=================== Store ============
            me.store = Ext.create('Ext.data.Store', {
                storedId: 'DataAbsensi',
                id: 'storeDataAbsensi',
                fields: ['ID', 'NIK', 'Nama', 'Tanggal', 'Masuk', 'Pulang', 'MasukLembur', 'PulangLembur', 'IDLokasi', 'namaLokasi'],
                proxy: {
                    type: 'ajax',
                    url: 'Absensi/GetListTodays',
                    reader: {
                        type: 'json',
                        root:'items'
                    }
                }
            });
            //======================================
            //=================== Grid Panel ==============
            me.GridPanel = Ext.create('Ext.grid.Panel', {
                store: Ext.data.StoreManager.lookup('DataAbsensi'),
                columns: [
                    { text: 'ID', width: 50, dataindex: 'ID' },
                    { text: 'NIK', width: 80, dataindex: 'NIK' },
                    { text: 'Nama', width: 200, dataindex: 'Nama' },
                    { text: 'Tanggal', width: 80, dataindex: 'Tanggal' },
                    { text: 'Masuk', width: 80, dataindex: 'Masuk' },
                    { text: 'Pulang', width: 80, dataindex: 'Pulang' },
                    { text: 'Masuk Lembur', width: 80, dataindex: 'MasukLembur' },
                    { text: 'Pulang Lembur', width: 80, dataindex: 'PulangLembur' },
                    { text: 'ID Lok', width: 80, dataindex: 'IDLokasi' },
                    { text: 'Lokasi', width: 80, dataindex: 'namaLokasi' }
                ],
                weight: '100%',
                height: 600,
            });
            //=================== end Grid Panel ==================
            
            Ext.applyIf(me, {items: [me.toolbar,me.GridPanel] });
            me.callParent(arguments);
        },
         showlist: function () {
            this.show(arguments);
            this.loadData();
        },
        loadData: function () {
            this.store.load({
                scope: this,
                callback: function (records, operation, success) { }
            });
            }
    });
    
    //===========================================================================================
    var AwalPeriode = Ext.create('Ext.menu.DatePicker', {
        handler: function (dp, date) {
            Ext.Msg.alert('Periode yang dipilih ','Periode Awal :' + Ext.Date.format(date, 'M j, Y'));        
        }
    });
    //===========================================================================================
    var AkhirPeriode = Ext.create('Ext.menu.DatePicker', {
        handler: function (dp, date) {
            Ext.Msg.alert('Periode yang dipilih ', 'Periode Akhir :' + Ext.Date.format(date, 'M j, Y'));
        }
    });

    cshtml
    Code:
    @{
        ViewBag.Title = "Absensi";
    }
    
    <h2></h2>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Absensi</title>
        <script src="~/Scripts/ext-all-debug.js"></script>
        <link href="~/Scripts/ExtJS/resources/ext-theme-gray/ext-theme-gray-all.css" rel="stylesheet" />
        <script src="~/Scripts/WebApp/HRDMEnu/Absensi.js"></script>
        <script src="~/Scripts/WebApp/Login.js"></script>
        <script src="~/Scripts/WebApp/Menu.js"></script>
        
    </head>
    <body>
        <script type="text/javascript">
            Ext.onReady(function () {
                var iHome = Ext.create('data.master.absensi');
                iHome.showlist();
            });
        </script>
    </body>
    </html>

  2. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120

    Default

    Hi jesdegar--

    Assuming that your data coming back from the server is okay, I think the issue is probably that you have a typo in the storeId property. It's storeId, not storedId.

    Hope that helps!

    Thanks
    Joel

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •