Telerik Forums
UI for ASP.NET MVC Forum
1 answer
249 views
Is there an easy way to enumerate through a list of controls such as datetime pickers or numeric controls and call the enable() method on them without specifying the id? Essentially I want to disable and enable a group of controls in a div.

Thanks!
Michael
Top achievements
Rank 1
 answered on 14 Feb 2013
8 answers
226 views
Hi,
Will there be a Kendo.Mvc.resources.dll for Swedish or do I need to compile my own file?

Regards,
Mattias
Daniel
Telerik team
 answered on 14 Feb 2013
1 answer
338 views
I'm using a tab strip to update a single View-model. I'm using only one form tag for my 3 tabs however the validation for all non-visible tabs doesn't fire the validation event. Is there any work around for this or is this expected behavior?
Daniel
Telerik team
 answered on 14 Feb 2013
1 answer
194 views
The outside portion of the grid with the pagination does not change size when detail templates are expanded. Is there a way to ensure the entire grid expands rather than displaying a scrollbar?

Thanks!
Michael
Top achievements
Rank 1
 answered on 14 Feb 2013
9 answers
230 views
I'd like to load a page with a grid of paged data where in MVC with the model i can set the first page of data to the grid.  thereby preventing the grid from retrieving it after the page loads.

so when you first hit the page and it loads the first page of data is already ready!

any ideas on how to accomplish this.  i guess i could set the data in JS at the bottom of the page and then set the datasource url instead of configuring it via the MVC helper.  seems hokey.
Daniel
Telerik team
 answered on 14 Feb 2013
1 answer
154 views
Hi, I have a problem with a kendo grid, in particular with the create method.
Let's suppose that we use that method for inserting a new data (which doesn't exist in the table). All works without problems.
Now let's suppose that we use the create method again to insert a second new data, different from the first one and compatible with the validation rules set in the application.
The problem is that I can't insert that data, because the validation rules prevent me to do that. Looking at the code in debug mode, I saw that I am passing to the create method a list of objects that contains the data I inserted before and the new element: it is so obvious that the validation rules, checking the first data, prevent me to insert new objects in the table. The same problem presents if I use the create method and then the update method.
I noticed, also, that if I refresh the web page before inserting the second data this problem doesn't occur: all works well.

Please, can you help me? I thought that I can proceed in two ways:
- by passing to the create method only the last inserted data
- by manually refreshing the grid everytime a new data is inserted or updated. How can I do this?

You can find the create and update methods in the controller, if you want.


THIS IS MY CODE

AnagraficaRepository.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Text;
using System.Threading.Tasks;
using Sopra.Fmspa.BusinessLayer.Models;
using Sopra.Fmspa.BusinessLayer.ViewModels;
using AutoMapper.Configuration;
using AutoMapper.Mappers;
 
 
/*   SINTASSI AUTOMAPPER
     AutoMapper.Mapper.CreateMap<Sorgente,Destinatario>();
     Destinatario dest = AutoMapper.Mapper.Map<Sorgente,Destinatario>(sorg);   */
 
 
 
namespace Sopra.Fmspa.BusinessLayer.DAL
{
    public class AnagraficaRepository : IAnagraficaRepository, IDisposable
    {
        private ODLModelContainer context;
 
 
        /*   TO DO:
         *   - vedere AnagraficaViewModel.cs
         *   - sistemare il codice in modo tale che questo mapper funzioni senza l'opzione ignore per il campo manifestazione
                                                                                                                  */
 
 
        //public AnagraficaRepository(ODLModelContainer context)
        //{
        //    this.context = context;
 
        //    AutoMapper.Mapper.CreateMap<TipologiaAnagrafica,TipologiaAnagraficaViewModel>();
        //    AutoMapper.Mapper.CreateMap<Padiglione,PadiglioneViewModel>();
        //    AutoMapper.Mapper.CreateMap<Manifestazione,ManifestazioneViewModel>();
 
        //    AutoMapper.Mapper.CreateMap<TipologiaAnagraficaViewModel,TipologiaAnagrafica>();
        //    AutoMapper.Mapper.CreateMap<PadiglioneViewModel,Padiglione>();
        //    AutoMapper.Mapper.CreateMap<ManifestazioneViewModel,Manifestazione>();
 
 
        //    AutoMapper.Mapper.CreateMap<Anagrafica,AnagraficaViewModel>()
        //        .ForMember(dest => dest.TipologiaAnagrafica, opt => opt.MapFrom(src => src.TipologiaAnagrafica))
        //        .ForMember(dest => dest.Padiglione, opt => opt.MapFrom(src => src.Padiglione))
        //        .ForMember(dest => dest.Manifestazione, opt => opt.MapFrom(src => src.Manifestazione));
 
        //    AutoMapper.Mapper.CreateMap<AnagraficaViewModel,Anagrafica>()
        //        .ForMember(dest => dest.TipologiaAnagrafica, opt => opt.MapFrom(src => src.TipologiaAnagrafica))
        //        .ForMember(dest => dest.Padiglione, opt => opt.MapFrom(src => src.Padiglione))
        //        .ForMember(dest => dest.Manifestazione, opt => opt.MapFrom(src => src.Manifestazione));
        //}
 
 
        public AnagraficaRepository(ODLModelContainer context)
        {
            this.context = context;
 
            AutoMapper.Mapper.CreateMap<TipologiaAnagrafica,TipologiaAnagraficaViewModel>();
            AutoMapper.Mapper.CreateMap<Padiglione,PadiglioneViewModel>();
            //AutoMapper.Mapper.CreateMap<Manifestazione, ManifestazioneViewModel>();
 
            AutoMapper.Mapper.CreateMap<TipologiaAnagraficaViewModel,TipologiaAnagrafica>();
            AutoMapper.Mapper.CreateMap<PadiglioneViewModel,Padiglione>();
            //AutoMapper.Mapper.CreateMap<ManifestazioneViewModel, Manifestazione>();
 
 
            AutoMapper.Mapper.CreateMap<AnagraficaInBianco,AnagraficaViewModel>()
                .ForMember(dest => dest.TipologiaAnagrafica, opt => opt.MapFrom(src => src.TipologiaAnagrafica))
                .ForMember(dest => dest.Padiglione, opt => opt.MapFrom(src => src.Padiglione));
                //.ForMember(dest => dest.Manifestazione, opt => opt.MapFrom(src => src.Manifestazione));
 
            AutoMapper.Mapper.CreateMap<AnagraficaViewModel, AnagraficaInBianco>()
                .ForMember(dest => dest.TipologiaAnagrafica, opt => opt.Ignore())
                .ForMember(dest => dest.Padiglione, opt => opt.Ignore())
                .ForMember(dest => dest.Manifestazione, opt => opt.Ignore());
        }
 
 
        //public AnagraficaRepository(ODLModelContainer context)
        //{
        //    this.context = context;
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        public IEnumerable<AnagraficaInBianco> GetAnagrafica()
        {
            return context.odl_AnagraficaInBianco.ToList();
        }
 
        public IList<AnagraficaViewModel> GetAnagraficaList()
        {
            List<AnagraficaInBianco> anag = context.odl_AnagraficaInBianco.ToList();
            List<AnagraficaViewModel> anagview = AutoMapper.Mapper.Map<List<AnagraficaInBianco>,List<AnagraficaViewModel>>(anag);
            return anagview;
        }
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        //public static IList<AnagraficaViewModel> All()
        //{
        //    IList<AnagraficaViewModel> result = (IList<AnagraficaViewModel>)HttpContext.Current.Session["Anagrafica"];
 
        //    if (result == null)
        //    {
        //        HttpContext.Current.Session["Anagrafica"] = result =
        //            (from anag in new ODLModelContainer().odl_Anagrafica
        //             select new AnagraficaViewModel
        //             {
        //                 Id = anag.Id,
        //                 AccountNumber = anag.AccountNumber,
        //                 RagioneSociale = anag.RagioneSociale,
        //                 TipologiaAnagraficaId = anag.TipologiaAnagraficaId,
        //                 Descrizione = anag.Descrizione,
        //                 ManifestazioneId = anag.ManifestazioneId,
        //                 PadiglioneId = anag.PadiglioneId,
        //                 Stand = anag.Stand,
        //                 FlagSolvenza = anag.FlagSolvenza,
        //                 FlagEstero = anag.FlagEstero,
 
        //                 TipologiaAnagrafica = anag.TipologiaAnagrafica,
        //                 Padiglione = anag.Padiglione
        //             }).ToList();
        //    }
 
        //    return result;
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        //public static AnagraficaViewModel One(Func<AnagraficaViewModel, bool> predicate)
        //{
        //    return All().Where(predicate).FirstOrDefault();
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        //public void Insert(AnagraficaViewModel anagview)
        //{
        //    if (anagview != null)
        //    {
        //        Anagrafica anag = AutoMapper.Mapper.Map<AnagraficaViewModel, Anagrafica>(anagview);
        //        context.odl_Anagrafica.Add(anag);
        //    }
        //}
 
 
        public void Insert(AnagraficaViewModel anagview)
        {
            if (anagview != null)
            {
                AnagraficaInBianco anag = AutoMapper.Mapper.Map<AnagraficaViewModel, AnagraficaInBianco>(anagview);
 
                // valore forzato
                anag.ManifestazioneId = anagview.ManifestazioneId;
 
                context.odl_AnagraficaInBianco.Add(anag);
            }
        }
 
 
        //public void Insert(AnagraficaViewModel anagview)
        //{
        //    Anagrafica anag = new Anagrafica();
 
        //    anag.Id = anagview.Id;
        //    anag.AccountNumber = anagview.AccountNumber;
        //    anag.RagioneSociale = anagview.RagioneSociale;
        //    anag.TipologiaAnagraficaId = anagview.TipologiaAnagraficaId;
        //    anag.Descrizione = anagview.Descrizione;
        //    anag.ManifestazioneId = anagview.ManifestazioneId;
        //    anag.PadiglioneId = anagview.PadiglioneId;
        //    anag.Stand = anagview.Stand;
        //    anag.FlagSolvenza = anagview.FlagSolvenza;
        //    anag.FlagEstero = anagview.FlagEstero;
 
        //    anag.TipologiaAnagrafica = anagview.TipologiaAnagrafica;
        //    anag.Padiglione = anagview.Padiglione;
 
        //    context.odl_Anagrafica.Add(anag);
        //}
 
 
        //public static void Insert(AnagraficaViewModel anag)
        //{
        //    anag.Id = All().OrderByDescending(p => p.Id).First().Id + 1;
 
        //    All().Insert(0, anag);
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        public void Update(AnagraficaViewModel anagview)
        {
            if (anagview != null)
            {
                AnagraficaInBianco anag = AutoMapper.Mapper.Map<AnagraficaViewModel,AnagraficaInBianco>(anagview);
                context.odl_AnagraficaInBianco.Attach(anag);
                context.Entry(anag).State = EntityState.Modified;
            }
        }
 
 
        //public void Update(AnagraficaViewModel anagview)
        //{
        //    Anagrafica anag = context.odl_Anagrafica.Find(anagview.Id);
 
        //    if (anag != null)
        //    {
        //        anag.Id = anagview.Id;
        //        anag.AccountNumber = anagview.AccountNumber;
        //        anag.RagioneSociale = anagview.RagioneSociale;
        //        anag.TipologiaAnagraficaId = anagview.TipologiaAnagraficaId;
        //        anag.Descrizione = anagview.Descrizione;
        //        anag.ManifestazioneId = anagview.ManifestazioneId;
        //        anag.PadiglioneId = anagview.PadiglioneId;
        //        anag.Stand = anagview.Stand;
        //        anag.FlagSolvenza = anagview.FlagSolvenza;
        //        anag.FlagEstero = anagview.FlagEstero;
 
        //        anag.TipologiaAnagrafica = anagview.TipologiaAnagrafica;
        //        anag.Padiglione = anagview.Padiglione;
 
        //        context.Entry(anag).State = EntityState.Modified;
        //    }
        //}
 
 
        //public static void Update(AnagraficaViewModel anag)
        //{
        //    AnagraficaViewModel target = One(p => p.Id == anag.Id);
        //    if (target != null)
        //    {
        //        target.AccountNumber = anag.AccountNumber;
        //        target.RagioneSociale = anag.RagioneSociale;
        //        target.TipologiaAnagraficaId = anag.TipologiaAnagraficaId;
        //        target.Descrizione = anag.Descrizione;
        //        target.ManifestazioneId = anag.ManifestazioneId;
        //        target.PadiglioneId = anag.PadiglioneId;
        //        target.Stand = anag.Stand;
        //        target.FlagSolvenza = anag.FlagSolvenza;
        //        target.FlagEstero = anag.FlagEstero;
 
        //        target.TipologiaAnagrafica = anag.TipologiaAnagrafica;
        //        target.Padiglione = anag.Padiglione;
        //    }
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        public void Delete(AnagraficaViewModel anagview)
        {
            AnagraficaInBianco anag = context.odl_AnagraficaInBianco.Find(anagview.Id);
            if (anag != null)
            {
                context.odl_AnagraficaInBianco.Remove(anag);
            }
        }
 
        //public static void Delete(AnagraficaViewModel anag)
        //{
        //    AnagraficaViewModel target = One(p => p.Id == anag.Id);
        //    if (target != null)
        //    {
        //        All().Remove(target);
        //    }
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        public void Save()
        {
            context.SaveChanges();
        }
 
 
        private bool disposed = false;
 
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    // dispose della classe context <--- dispose della classe ODLModelContainer
                    context.Dispose();
                }
            }
            this.disposed = true;
        }
 
        public void Dispose()
        {
            // dispose della classe IDisposable ---> GC ---> liberazione della memoria
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }
}
 
 
 
/*   TO DO:
 *   - aggiungere la possibilità di scegliere, per ogni record della grid, una manifestazione
 *   - collegamento tra la pagina manifestazioni e questa pagina (anagrafica in bianco)
                                                                                                                   */

AnagraficaViewModel.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sopra.Fmspa.BusinessLayer.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Sopra.Fmspa.BusinessLayer.ViewModelsValidators;
 
namespace Sopra.Fmspa.BusinessLayer.ViewModels
{
    [FluentValidation.Attributes.Validator(typeof(AnagraficaViewModelValidator))]
    public class AnagraficaViewModel
    {
        //[Required(ErrorMessage = "Il campo Id è obbligatorio")]
        [Display(Name = "Id Anagrafica")]
        [DisplayFormat(NullDisplayText = "Id assente")]
        [ScaffoldColumn(false)]
        public int Id { get; set; }
 
        public string AccountNumber { get; set; }
 
        //[Required(ErrorMessage = "Il campo Ragione Sociale è obbligatorio")]
        [Display(Name = "Ragione Sociale")]
        //[DisplayFormat(NullDisplayText = "")]
        public string RagioneSociale { get; set; }
 
        //  //[Required(ErrorMessage = "Il campo Tipologia Anagrafica è obbligatorio")]
        [Display(Name = "Id Tipologia Anagrafica")]
        [DisplayFormat(NullDisplayText = "Id assente")]
        [ScaffoldColumn(false)]
        public string TipologiaAnagraficaId { get; set; }
 
        //  //[Required(ErrorMessage = "Il campo Descrizione è obbligatorio")]
        [DisplayFormat(NullDisplayText = "")]
        public string Descrizione { get; set; }
 
        //  //[Required(ErrorMessage = "Il campo Manifestazione è obbligatorio")]
        [Display(Name = "Id Manifestazione")]
        [DisplayFormat(NullDisplayText = "Id assente")]
        [ScaffoldColumn(false)]
        public string ManifestazioneId { get; set; }
 
        //  //[Required(ErrorMessage = "Il campo Padiglione è obbligatorio")]
        [Display(Name = "Id Padiglione")]
        [DisplayFormat(NullDisplayText = "Id assente")]
        [ScaffoldColumn(false)]
        public string PadiglioneId { get; set; }
 
        //  //[Required(ErrorMessage = "Il campo Stand è obbligatorio")]
        [DisplayFormat(NullDisplayText = "")]
        public string Stand { get; set; }
 
        public bool FlagSolvenza { get; set; }
 
        public bool FlagEstero { get; set; }
 
 
        //[Required(ErrorMessage = "Il campo Tipologia Anagrafica è obbligatorio")]
        [Display(Name = "Tipologia Anagrafica")]
        //[DisplayFormat(NullDisplayText = "")]
        public virtual TipologiaAnagraficaViewModel TipologiaAnagrafica { get; set; }
 
        //[Required(ErrorMessage = "Il campo Padiglione è obbligatorio")]
        [Display(Name = "Padiglione")]
        //[DisplayFormat(NullDisplayText = "")]
        public virtual PadiglioneViewModel Padiglione { get; set; }
 
 
        /*   TO DO:
         *   - reintrodurre il riferimento virtual alla classe manifestazione? Oppure tenere solo l'id number?
         *   - impostare il viewmodel in modo tale che, per ogni record inserito, possa essere specificata una manifestazione
                                                                                                   */
 
        //[Required(ErrorMessage = "Il campo Manifestazione è obbligatorio")]
        //[Display(Name = "Manifestazione")]
        //public virtual PadiglioneViewModel ManifestazioneViewModel { get; set; }
    }
}

ManifestazioneViewModel.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sopra.Fmspa.BusinessLayer.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Sopra.Fmspa.BusinessLayer.ViewModelsValidators;
 
namespace Sopra.Fmspa.BusinessLayer.ViewModels
{
    [FluentValidation.Attributes.Validator(typeof(ManifestazioneViewModelValidator))]
    public class ManifestazioneViewModel
    {
        //  //[Required(ErrorMessage = "Il campo Manifestazione è obbligatorio")]
        [Display(Name = "Id Manifestazione")]
        [DisplayFormat(NullDisplayText = "Id assente")]
        [ScaffoldColumn(false)]
        public string Id { get; set; }
 
        //  //[Required(ErrorMessage = "Il campo Manifestazione è obbligatorio")]
        [Display(Name = "Descrizione Manifestazione")]
        [DisplayFormat(NullDisplayText = "")]
        public string Descrizione { get; set; }
 
        [DisplayFormat(DataFormatString = "{0:dd/mm/yyyy}", ApplyFormatInEditMode = true)]
        public System.DateTime DataInizio { get; set; }
 
        [DisplayFormat(DataFormatString = "{0:dd/mm/yyyy}", ApplyFormatInEditMode = true)]
        public System.DateTime DataFine { get; set; }
    }
}

PadiglioneViewModel.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sopra.Fmspa.BusinessLayer.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Sopra.Fmspa.BusinessLayer.ViewModelsValidators;
 
namespace Sopra.Fmspa.BusinessLayer.ViewModels
{
    [FluentValidation.Attributes.Validator(typeof(PadiglioneViewModelValidator))]
    public class PadiglioneViewModel
    {
        //  //[Required(ErrorMessage = "Il campo Padiglione è obbligatorio")]
        [Display(Name = "Id Padiglione")]
        [DisplayFormat(NullDisplayText = "Id assente")]
        [ScaffoldColumn(false)]
        public string Id { get; set; }
 
        //  //[Required(ErrorMessage = "Il campo Padiglione è obbligatorio")]
        [Display(Name = "Descrizione Padiglione")]
        [DisplayFormat(NullDisplayText = "")]
        public string Descrizione { get; set; }
    }
}

AnagraficaController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Sopra.Fmspa.BusinessLayer.Models;
using Sopra.Fmspa.BusinessLayer.DAL;
using Sopra.Fmspa.BusinessLayer.ViewModels;
using System.Data.Entity.Validation;
using System.Diagnostics;
using AutoMapper.Configuration;
using AutoMapper.Mappers;
 
 
/*   SINTASSI AUTOMAPPER
     AutoMapper.Mapper.CreateMap<Sorgente,Destinatario>();
     Destinatario dest = AutoMapper.Mapper.Map<Sorgente,Destinatario>(sorg);   */
 
 
 
namespace Sopra.Fmspa.BusinessLayer.Controllers
{
 
    public class AnagraficaController : Controller
    {
        ODLModelContainer db = new ODLModelContainer();
        private IAnagraficaRepository anagraficaRepository;
 
 
        //public AnagraficaController()
        //{
        //    this.anagraficaRepository = new AnagraficaRepository(new ODLModelContainer());
 
        //    AutoMapper.Mapper.CreateMap<TipologiaAnagrafica,TipologiaAnagraficaViewModel>();
        //    AutoMapper.Mapper.CreateMap<Padiglione,PadiglioneViewModel>();
        //    AutoMapper.Mapper.CreateMap<Manifestazione,ManifestazioneViewModel>();
 
        //    AutoMapper.Mapper.CreateMap<TipologiaAnagraficaViewModel,TipologiaAnagrafica>();
        //    AutoMapper.Mapper.CreateMap<PadiglioneViewModel,Padiglione>();
        //    AutoMapper.Mapper.CreateMap<ManifestazioneViewModel,Manifestazione>();
 
 
        //    AutoMapper.Mapper.CreateMap<Anagrafica,AnagraficaViewModel>()
        //        .ForMember(dest => dest.TipologiaAnagrafica, opt => opt.MapFrom(src => src.TipologiaAnagrafica))
        //        .ForMember(dest => dest.Padiglione, opt => opt.MapFrom(src => src.Padiglione))
        //        .ForMember(dest => dest.Manifestazione, opt => opt.MapFrom(src => src.Manifestazione));
 
        //    AutoMapper.Mapper.CreateMap<AnagraficaViewModel,Anagrafica>()
        //        .ForMember(dest => dest.TipologiaAnagrafica, opt => opt.MapFrom(src => src.TipologiaAnagrafica))
        //        .ForMember(dest => dest.Padiglione, opt => opt.MapFrom(src => src.Padiglione))
        //        .ForMember(dest => dest.Manifestazione, opt => opt.MapFrom(src => src.Manifestazione));
 
        //    //AutoMapper.Mapper.CreateMap<AnagraficaViewModel,AnagraficaViewModel>();
        //}
 
 
        public AnagraficaController()
        {
            this.anagraficaRepository = new AnagraficaRepository(new ODLModelContainer());
 
            AutoMapper.Mapper.CreateMap<TipologiaAnagrafica,TipologiaAnagraficaViewModel>();
            AutoMapper.Mapper.CreateMap<Padiglione,PadiglioneViewModel>();
            //AutoMapper.Mapper.CreateMap<Manifestazione,ManifestazioneViewModel>();
 
            AutoMapper.Mapper.CreateMap<TipologiaAnagraficaViewModel,TipologiaAnagrafica>();
            AutoMapper.Mapper.CreateMap<PadiglioneViewModel,Padiglione>();
            //AutoMapper.Mapper.CreateMap<ManifestazioneViewModel,Manifestazione>();
 
 
            AutoMapper.Mapper.CreateMap<AnagraficaInBianco,AnagraficaViewModel>()
                .ForMember(dest => dest.TipologiaAnagrafica, opt => opt.MapFrom(src => src.TipologiaAnagrafica))
                .ForMember(dest => dest.Padiglione, opt => opt.MapFrom(src => src.Padiglione));
                //.ForMember(dest => dest.Manifestazione, opt => opt.MapFrom(src => src.Manifestazione));
 
            AutoMapper.Mapper.CreateMap<AnagraficaViewModel,AnagraficaInBianco>()
                .ForMember(dest => dest.TipologiaAnagrafica, opt => opt.Ignore())
                .ForMember(dest => dest.Padiglione, opt => opt.Ignore())
                .ForMember(dest => dest.Manifestazione, opt => opt.Ignore());
 
            //AutoMapper.Mapper.CreateMap<AnagraficaViewModel,AnagraficaViewModel>();
        }
 
 
        public AnagraficaController(IAnagraficaRepository anagraficaRepository)
        {
            this.anagraficaRepository = anagraficaRepository;
        }
 
 
        public ActionResult Remote_Data()
        {
            return View("AjaxBinding");
        }
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        public ActionResult AnagraficaRistoratoriEspositori()
        {
            IList<AnagraficaViewModel> anagview = anagraficaRepository.GetAnagraficaList();
 
            PopulateTipologiaAnagrafica();
            PopulatePadiglione();
 
            return View(anagview);
        }
 
 
        //public ActionResult AnagraficaRistoratoriEspositori()
        //{
        //    IEnumerable<Anagrafica> anag = anagraficaRepository.GetAnagrafica();
 
        //    PopulateTipologiaAnagrafica();
        //    PopulatePadiglione();
 
        //    return View(anag);
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        public ActionResult Anagrafiche_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(anagraficaRepository.GetAnagraficaList().ToDataSourceResult(request));
        }
 
 
        //public ActionResult Anagrafiche_Read([DataSourceRequest] DataSourceRequest request)
        //{
        //    return Json(AnagraficaRepository.All().ToDataSourceResult(request));
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        public ActionResult Anagrafiche_RagioneSocialeFilter()
        {
            return Json(anagraficaRepository.GetAnagraficaList().Select(e => e.RagioneSociale).Distinct(), JsonRequestBehavior.AllowGet);
        }
 
        public ActionResult Anagrafiche_TipologiaAnagraficaFilter()
        {
            return Json(anagraficaRepository.GetAnagraficaList().Select(e => e.TipologiaAnagrafica).Distinct(), JsonRequestBehavior.AllowGet);
        }
 
        public ActionResult Anagrafiche_PadiglioneFilter()
        {
            return Json(anagraficaRepository.GetAnagraficaList().Select(e => e.Padiglione).Distinct(), JsonRequestBehavior.AllowGet);
        }
 
        public ActionResult Anagrafiche_FlagEsteroFilter()
        {
            return Json(anagraficaRepository.GetAnagraficaList().Select(e => e.FlagEstero).Distinct(), JsonRequestBehavior.AllowGet);
        }
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        //[AcceptVerbs(HttpVerbs.Post)]
        //public ActionResult Anagrafiche_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        //{
        //    if (anagrafiche != null && ModelState.IsValid)
        //    {
        //        foreach (var anag in anagrafiche)
        //        {
        //            anagraficaRepository.Insert(anag);
        //        }
        //        anagraficaRepository.Save();
        //    }
        //    return Json(ModelState.ToDataSourceResult());
        //}
 
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Anagrafiche_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        {
            if (anagrafiche != null && ModelState.IsValid)
            {
                foreach (var anag in anagrafiche)
                {
                    anag.Id = anagraficaRepository.GetAnagrafica().OrderByDescending(p => p.Id).First().Id + 1;
                    anag.TipologiaAnagraficaId = anag.TipologiaAnagrafica.Id;
                    anag.PadiglioneId = anag.Padiglione.Id;
 
                    // valore forzato
                    if (anag.ManifestazioneId == null)
                    {
                        //anag.Manifestazione.Id = anagraficaRepository.GetAnagrafica().OrderByDescending(p => p.Id).First().Manifestazione.Id;
                        anag.ManifestazioneId = anagraficaRepository.GetAnagrafica().OrderByDescending(p => p.Id).First().ManifestazioneId;
                    }
                    //anag.ManifestazioneId = anag.Manifestazione.Id;
 
                    anagraficaRepository.Insert(anag);
                }
                anagraficaRepository.Save();
            }
            return Json(ModelState.ToDataSourceResult());
        }
 
 
        //[AcceptVerbs(HttpVerbs.Post)]
        //public ActionResult Anagrafiche_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        //{
        //    var results = new List<AnagraficaViewModel>();
        //    if (anagrafiche != null && ModelState.IsValid)
        //    {
        //        foreach (var anag in anagrafiche)
        //        {
        //            anagraficaRepository.Insert(anag);
        //            results.Add(anag);
        //        }
        //        anagraficaRepository.Save();
        //    }
        //    return Json(results.ToDataSourceResult(request, ModelState));
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        private void PopulateTipologiaAnagrafica()
        {
            ViewData["TipologiaAnagrafiche"] = AutoMapper.Mapper.Map<IList<TipologiaAnagrafica>,IList<TipologiaAnagraficaViewModel>>(db.odl_TipologiaAnagrafica.ToList());
        }
 
        private void PopulatePadiglione()
        {
            ViewData["Padiglioni"] = AutoMapper.Mapper.Map<IList<Padiglione>,IList<PadiglioneViewModel>>(db.odl_vw_PADIGLIONI.ToList());
        }
 
 
        public ActionResult GetData()
        {
            return Json(anagraficaRepository.GetAnagraficaList(), JsonRequestBehavior.AllowGet);
        }
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        //[AcceptVerbs(HttpVerbs.Post)]
        //public ActionResult Anagrafiche_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        //{
        //    if (anagrafiche != null && ModelState.IsValid)
        //    {
        //        foreach (var anag in anagrafiche)
        //        {
        //            anag.TipologiaAnagrafica.Id = anag.TipologiaAnagraficaId;
        //            anag.Padiglione.Id = anag.PadiglioneId;
        //            anag.Manifestazione.Id = anag.ManifestazioneId;
 
        //            anagraficaRepository.Update(anag);
        //        }
        //        anagraficaRepository.Save();
        //    }
        //    return Json(ModelState.ToDataSourceResult());
        //}
 
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Anagrafiche_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        {
            if (anagrafiche != null && ModelState.IsValid)
            {
                foreach (var anag in anagrafiche)
                {
                    anag.TipologiaAnagrafica.Id = anag.TipologiaAnagraficaId;
                    anag.Padiglione.Id = anag.PadiglioneId;
                    //anag.Manifestazione.Id = anag.ManifestazioneId;
 
                    anagraficaRepository.Update(anag);
                }
                anagraficaRepository.Save();
            }
            return Json(ModelState.ToDataSourceResult());
        }
 
 
        //[AcceptVerbs(HttpVerbs.Post)]
        //public ActionResult Anagrafiche_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        //{
        //    if (anagrafiche != null && ModelState.IsValid)
        //    {
        //        foreach (var anag in anagrafiche)
        //        {
        //            var target = AnagraficaRepository.One(p => p.Id == anag.Id);
        //            if (target != null)
        //            {
        //                target = AutoMapper.Mapper.Map<AnagraficaViewModel, AnagraficaViewModel>(anag);
        //                anagraficaRepository.Update(target);
        //            }
        //        }
        //        anagraficaRepository.Save();
        //    }
        //    return Json(ModelState.ToDataSourceResult());
        //}
 
 
        //[AcceptVerbs(HttpVerbs.Post)]
        //public ActionResult Anagrafiche_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        //{
        //    if (anagrafiche != null && ModelState.IsValid)
        //    {
        //        foreach (var anag in anagrafiche)
        //        {
        //            var target = AnagraficaRepository.One(p => p.Id == anag.Id);
        //            if (target != null)
        //            {
        //                target.AccountNumber = anag.AccountNumber;
        //                target.RagioneSociale = anag.RagioneSociale;
        //                target.TipologiaAnagraficaId = anag.TipologiaAnagraficaId;
        //                target.Descrizione = anag.Descrizione;
        //                target.ManifestazioneId = anag.ManifestazioneId;
        //                target.PadiglioneId = anag.PadiglioneId;
        //                target.Stand = anag.Stand;
        //                target.FlagSolvenza = anag.FlagSolvenza;
        //                target.FlagEstero = anag.FlagEstero;
 
        //                target.TipologiaAnagrafica = anag.TipologiaAnagrafica;
        //                target.Padiglione = anag.Padiglione;
 
        //                anagraficaRepository.Update(target);
        //            }
        //        }
        //        anagraficaRepository.Save();
        //    }
        //    return Json(ModelState.ToDataSourceResult());
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
        public ActionResult Anagrafiche_Delete([Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        {
            if (anagrafiche.Any())
            {
                Anagrafiche_Destroy(anagrafiche);
            }
            else
            {
                return HttpNotFound();
            }
 
            return Json(ModelState.ToDataSourceResult());
        }
 
        [HttpPost, ActionName("Anagrafiche_Delete")]
        public void Anagrafiche_Destroy([Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        {
            if (ModelState.IsValid)
            {
                foreach (var anag in anagrafiche)
                {
                    anagraficaRepository.Delete(anag);
                }
            }
            anagraficaRepository.Save();
        }
 
 
        //[AcceptVerbs(HttpVerbs.Post)]
        //public ActionResult Anagrafiche_Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<AnagraficaViewModel> anagrafiche)
        //{
        //    if (anagrafiche.Any() && ModelState.IsValid)
        //    {
        //        foreach (var anag in anagrafiche)
        //        {
        //            anagraficaRepository.Delete(anag);
        //        }
        //    }
        //    anagraficaRepository.Save();
 
        //    return Json(ModelState.ToDataSourceResult());
        //}
 
 
//   ---------------------------------------------------------------------------------------------- //
 
 
    }
 
}
 
 
 
/*   TO DO:
 *   - aggiungere la possibilità di scegliere, per ogni record della grid, una manifestazione
 *   - collegamento tra la pagina manifestazioni e questa pagina (anagrafica in bianco)
                                                                                                                   */
Stefano
Top achievements
Rank 1
 answered on 14 Feb 2013
3 answers
248 views
I get an invalid template when using tabstrips in the following scenario:

grid -> popup edit - popup has a grid - this grid has a popup for edit - and that popup has a tabstrip.

I believe it is caused the by the hashtag on the href below for the tabs.

<a class="k-link" href="#choiceDetailTabstrip-2">HTML Fragment</a>

Please advise.

Thanks.

Rene.

Edit:  It may also be due to jQuery("#choiceDetailTabstrip").kendoTabStrip( ..

The hash tags are not escaped ... as well - I also have a Kendo editor in one of the tabs...
Dimiter Madjarov
Telerik team
 answered on 14 Feb 2013
4 answers
553 views
Hello again,
I'm trying to use the multiple selection feature,how can i get the selected rows data also on client side,and on server side(using an action)?

Many thanks again,
Atanas Korchev
Telerik team
 answered on 14 Feb 2013
8 answers
2.1K+ views
Hello. I'm using the Kendo grid, and most everything works well. However, when I set it to use Ajax for its datasource, it starts displaying the Date in JSON format (ex: /Date(1281538860000)/ ) in the grid.

If I change it back to a Server datasouce, it is displayed correctly as a DateTime.

Here is my grid:  (My date object is currently a nullable DateTime? field, not a property.)

@(Html.Kendo().Grid(Model)
    .Name("IssuesGrid")
    .Columns(column =>
        
            column.Bound(i => i.Id.Value).Title("Id"); 
            column.Bound(i => i.SubmitDate.Value).Title("Submitted");   
        })
    .Pageable()
    .Sortable()
    .Filterable()
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
    .Events(events => events.Change("rowSelected"))
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(15)
        .Read("GetIssuesAsync", "Issues")
        .Model(model => model.Id(i => i.Id))))

Ajax action:
public JsonResult GetIssuesAsync([DataSourceRequest]DataSourceRequest request)
{
    var issues = TempContext.GetIssues().ToDataSourceResult(request);
    return Json(issues);
}

I tried using the latest internal build but it doesn't seem to fix this.
Any help would be much appreciated. Thanks.
Brian
Top achievements
Rank 1
 answered on 14 Feb 2013
3 answers
701 views
Hi,
I am using trial version of Kendo UI and trying to use Grid control.

I am referring the example shown in link http://demos.kendoui.com/web/grid/index.html and looking at Basic Usage.

I am using ASP.NET MVC 4 Razor, and I got Kendo Grid working on a page, but only thing is I am not able to get paging working on it.
the example shown for cshtml page doesn't show how to configure page size but html example shows , so not sure how to set paging limit set in cshtml page?

can you please help?
hash
Top achievements
Rank 1
 answered on 13 Feb 2013
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?