Telerik Forums
Kendo UI for jQuery Forum
3 answers
849 views
Hi,

I have nullable datetime (in UI and as date in DB) field for birth date. But when I click on Edit action in grid, It still displays as yyyy/MM/dd instead of yyyy-MM-dd. Hence I am getting BirthDay is not valid date error message. I have not written any explicit validation.

In my cshtml page I have formatted it as:
columns.Bound(r => r.BirthDay).Width(100).Format("{0:yyyy-MM-dd}");

In my model I have initialized as:
[Display(Name = "Birth Day")]
[DataType(DataType.Date)]        
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime? BirthDay { get; set; }

I can however generalized and apply formatting for my entire site by below code in global.asax but I want to apply it for specific pages only.
protected void Application_BeginRequest()
{
            CultureInfo info = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
            info.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
            System.Threading.Thread.CurrentThread.CurrentCulture = info;
}

Please help!

Thanks,
Nirav
Vladimir Iliev
Telerik team
 answered on 10 Apr 2013
1 answer
153 views
How to get the grid's rows count ?My grid has data,but the code shows 0 row..
 alert($('#Grid').data("kendoGrid").tbody.find('>tr.k-master-row').length);
Atanas Korchev
Telerik team
 answered on 10 Apr 2013
7 answers
921 views
where can I find some documentation / examples with Qunit or Jasmine for something such as testing if data is bound to a grid? or upon selecting a row, data is present?
Atanas Korchev
Telerik team
 answered on 10 Apr 2013
3 answers
151 views
Hi,

I tried this format "# y.o." (as in age years old), and it crashed my IDE. It never appeared on the page correctly either.
Georgi Krustev
Telerik team
 answered on 10 Apr 2013
4 answers
40 views
Hi There!

I am currently building a KendoUI+PhoneGap app combination. This app has several windows and each of these windows have separate styles.

Is there a way to separate the CSS styles for each of these windows so that other windows' styling does not get affected. In my current structure, even though I code each window on separate html files, when I run the app, it seems that all the files are being combined into one and so the CSS of one window sometimes overrides the others.

What is the best way to get around this? Does anyone of you have had the same problem? Please help! Many thanks in advance!


Many thanks!

Best regards,
Antonio
Antonio
Top achievements
Rank 1
 answered on 10 Apr 2013
1 answer
363 views
Hi,

My code works fine the first time around. The second time, if I change the cascadign dropdownlist , the treeview turns up null.

View - cshtml file
@using MedAssets.AMS.Workflow.Rules
@using MedAssets.AMS.Web.ViewModels
  
@model RulesViewModel
  
        <table border="1" width="50%">
            <tr>
                <td style="width: 20%">@Html.Label("Name :") </td>
                <td>@Html.TextBoxFor(m => m.Rule.Name)</td>
            </tr>
            <tr>
                <td>@Html.Label("Status")</td>
                <td>@Html.CheckBoxFor(m => m.Rule.IsActive) @Html.Label("Active")</td>
  
            </tr>
  
            <tr>
            </tr>
        </table>
        <div style="height: 50px;"></div>
        <table id="tblFacility">
            <tr>
                <td>
                    @foreach (var objFacility in Model.FacilityList)
                    {
                     
                        <div>
                             
                            @Html.CheckBox(objFacility.FacilityId.ToString(), new { id = objFacility.FacilityId.ToString() })
                            @Html.Label(objFacility.FacilityId.ToString(), objFacility.FacilityName, new { @for = objFacility.FacilityId.ToString() })
                        </div>
                    }
                </td>
            </tr>
        </table>
        <div style="height: 50px"></div>
        <table id="tblRulePart" width="auto" border="1">
            <tr>
                @* <td style="width: 10px">
                @Html.Label("Compare")
            </td>*@
                <td style="width: 30px" align="center" class="k-header">
                    @Html.Label("Account Context")
                </td>
                <td style="width: 100px" align="center" class="k-header">
                    @Html.Label("Rule Property")
                </td>
                <td style="width: 100px" align="center" class="k-header">
                    @Html.Label("Comparison Operator")
                </td>
  
                <td style="width: 400px" align="center" class="k-header">
                    @* @Html.Label("Property Values")*@
                </td>
                <td style="width: 40px" align="center" class="k-header">
                    @Html.Label("")
                </td>
  
  
            </tr>
            <tr>
                @* <td>
                @Html.CheckBox("chkCompare", false)
            </td>*@
                <td align="center">
                    @(Html.Kendo().DropDownList()
                .Name("Context")
                .OptionLabel("--Select Context--")
                .DataTextField("Text")
                .DataValueField("Value")
                .AutoBind(false)
                .BindTo(Model.RuleAccountContextList)
  
                )
  
                </td>
                <td align="center">
                    @(Html.Kendo().DropDownList()
                .Name("Attribute")
                .HtmlAttributes(new { style = "width:200px" })
                .OptionLabel("--Select Attribute--")
                .DataTextField("DisplayName")
                .DataValueField("Id")
                .AutoBind(false)
                .BindTo(Model.RuleAttributeModelList)
                              
                )
                </td>
                <td align="center">
                    @(Html.Kendo().DropDownList()
                .Name("RuleCompare")
                .HtmlAttributes(new { style = "width:200px" })
                .OptionLabel("--Comparison--")
                .DataTextField("DisplayName")
                .DataValueField("Id")
                .CascadeFrom("Attribute")
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("GetCascadeOperators", "Rule")
                            .Data("filterOperator");
                    })
                    .ServerFiltering(true);
                })
              .Enable(false)
              .AutoBind(false)
  
  
                )
  
                    <script>
                        function filterOperator() {
  
                            return {
                                property: $("#Attribute").val() + "*" + $("#Context").val()
  
                            };
                        }
                    </script>
                </td>
                <td align="left">
                    <div id="list">
                        <table>
                            <tr>
  
                                <td>
                                    <div style="height: 100px; width:400px; overflow-y: auto">
                                        <div id="treeView"></div>
                                    </div>
  
                                </td>
  
  
                            </tr>
  
                        </table>
                    </div>
  
                </td>
                <td align="center">
                    <input id="btnAdd" type="submit" name="AddRulePart" value="ADD" />
                </td>
            </tr>
            <tr>
            </tr>
        </table>
  
  
        <script type="text/javascript">
            var selectedTreeNodes = new Array();
            var saveData = new Array();
            $(document).ready(
               function () {
  
                   $("#Context").change(function () {
                       var selectedId = $('#Context').val();
                       if (selectedId == 3) {
                           $('#list').hide();
                       }
                       else {
                           $('#list').show();
                       }
                   })
  
  
                   $('#Attribute').change(function () {
                       var selectedId = $('#Attribute').val();
                       var selectedFacility = new Array();
                       $("#tblFacility").find("input:checked").each(function () {
                           var facId = $(this).attr('name');
                           var facname = $('label[for=' + facId + ']').text();
                           selectedFacility.push({ 'FacilityId': facId, 'FacilityName': facname });
                       });
                       var facData = JSON.stringify(selectedFacility);
                       var selData = { 'id': selectedId, 'facilityIds': facData };
  
                       $.ajax({
  
                           url: "GetAttributeValues",
                           data: selData,
                           type: "GET",
                           success: function (result) {
                              // debugger;
                               var tempView = $("#treeView").data("kendoTreeView");
  
                               var treeObj = [];
                               for (var i = 0; i < result.length; i++) {
                                   treeObj.push({ id: result[i].id, Name: result[i].Name, items: result[i].Children, hasChildren: result[i].hasChildren  });
                               }
  
  
                               var treeDs = new kendo.data.HierarchicalDataSource(
                                                       {
                                                           data: treeObj
                                                       });
                               //if (tempView == null || tempView == undefined || tempView.data == null) {
                                   //tempView.dataSource.data([]);
                                   //tempView.dataSource.data(result);
                               //}
                                
                               $("#treeView").kendoTreeView(
                                   {
                                       dataSource: result,
                                       dataTextField: "Name",
                                       hasChildren : "hasChildren",
                                       dataValueField: "id",
                                       loadOnDemand: true,
                                       expanded: true,
                                         
                                         
                                         
                                       checkboxTemplate: kendo.template($("#treeview-checkbox-template").html()),
                                   });
                           },
                           error: function () {
                               //alert("error");
                           },
                       });
                   })
                     
                     
  
  
                   function getNodeIndex(node) {
                       return node.parentsUntil(".k-treeview", ".k-item").map(function () {
                           return $(this).index();
                       }).toArray().reverse().join(":");
                   }
  
                    
                    
                    
                   var treeview = $("#treeView");
                   treeview.on("change", ":checkbox", function (e) {
                       //var checkbox = $(this),
                       //    dataItem = treeview.data("kendoTreeView").dataItem(checkbox.closest(".k-item")),
                       //    index = getNodeIndex(checkbox);
  
                     //  debugger;
                       var nodeDesc = '';
                       var nodeId = 0;
                       if ($(this).is(':checked')) {
                           nodeId = $(this).attr('value');
                           $(this).parent().siblings().each(function () {
                               var text = $(this).text();
                               if (text && text != undefined) {
                                   nodeDesc = text.replace(/&/g, '&');
                                   return false;
                               }
                           });
                           //uncheck all checked checkboxes
                           //$("input:checked[name=checkedNodes]").each(function () {
                           //    $(this).attr('checked', false);
                           //});
                           ////recheck this
                           //$(this).attr('checked', true);
                       }
                       selectedTreeNodes.push({ "NodeId": nodeId, "NodeDesc": nodeDesc });
                    })
               });
  
  
            $("#btnAdd").click(function () {
                  
  
                var ddlContext = $("#Context").data("kendoDropDownList");
                var contextDataItem = ddlContext.text();
                var contextId = $("#Context").val();
  
                var ddlAttribute = $("#Attribute").data("kendoDropDownList");
                var attrDataItem = ddlAttribute.text();
                var attrtId = $("#Attribute").val();
  
                var ddlRuleCompare = $("#RuleCompare").data("kendoDropDownList");
                var cmpDataItem = ddlRuleCompare.text();
                var cmpId = $("#RuleCompare").val();
  
                var selFaclist = [];
                $("#tblFacility").find("input:checked").each(function () {
                    var facId = $(this).attr('name');
                    var facname = $('label[for=' + facId + ']').text();
                    selFaclist.push({ 'FacilityId': facId, 'FacilityName': facname });
                });
                  
  
                  
  
                //var rulePartMemberList;
                //for (var i = 0; i < selectedTreeNodes.length; i++)
  
  
                var seldata = {
                    "ContextId": contextId,
                    "ContextValue": contextDataItem,
                    "AttributeId": attrtId,
                    "AttributeValue": attrDataItem,
                    "CompareId": cmpId,
                    "CompareValue": cmpDataItem,
                    "SelectedFacility" :selFaclist,
                    "SelectedValues": selectedTreeNodes,
                };
  
  
                //saveData.push({ "Data": seldata });
  
                saveData.push({
                    "ContextId": contextId,
                    "ContextValue": contextDataItem,
                    "AttributeId": attrtId,
                    "AttributeValue": attrDataItem,
                    "CompareId": cmpId,
                    "CompareValue": cmpDataItem,
                    "SelectedFacility": selFaclist,
                    "SelectedValues": selectedTreeNodes,
                });
  
                var jsonObj = [];
                for (var i = 0; i < selectedTreeNodes.length; i++) {
                    jsonObj.push({ id: selectedTreeNodes[i].NodeId, optionValue: selectedTreeNodes[i].NodeDesc });
                }
  
             
                var dataDefault = new kendo.data.HierarchicalDataSource(
                                        {
                                            data: jsonObj
                                        });
                  
                 
  
                var col1 = "<td style='width: 30px' align='center'>" + contextDataItem + "</td>";
                var col2 = "<td style='width: 100px' align='center'>" + attrDataItem + "</td>";
                var col3 = "<td style='width: 100px' align='center'>" + cmpDataItem + "</td>";
                var col4 = "<td style='width: 100px' align='left'> <div id='treeview'></div></td>";
                var col5 = "<td align='center'><a onclick='removeRow(this);' href='#' class='delete-link' > Delete  </a></td>";
  
                var nextRow = $("<tr>" + col1 + col2 + col3 + col4 + col5 + "</tr>");
                $('#tblRulePart tr:last').after(nextRow);
  
  
                $("#treeview").kendoTreeView({
                    checkboxes: {
  
                        checkChildren: false,
                        template: kendo.template(
                            '<input type ="checkbox" checked="checked" />')
                    },
  
                    dataSource: dataDefault,
                    dataTextField: "optionValue",
                    dataValueField: "id",
                });
  
                selectedTreeNodes = [];
                
                return false;
                               
            });
  
            function removeRow() {
  
                if (!confirm('Are you sure you want to delete?')) {
                    ev.preventDefault();
                    return false;
                } else {
                    $("#tblRulePart").delegate('a.delete-link', 'click', function (e) {
                        e.preventDefault();
                        $(this).closest('tr').remove();
                    });
                }
            }
  
        </script>
  
        <script id="treeview-checkbox-template" type="text/kendo-ui-template">
        <input type="checkbox" name="checkedFiles[#= item.id #]" value="#= item.id #" />
        </script>
  
    </div>

Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MedAssets.AMS.Business.Domain.Common;
using MedAssets.AMS.Business.Domain;
using MedAssets.AMS.Business.Domain.Enums;
using MedAssets.AMS.Business.Domain.Interfaces;
using MedAssets.AMS.Business.Domain.Managers.Interfaces;
//using MedAssets.Aaa.Security;
//using MedAssets.Aaa.Users;
using MedAssets.AMS.Business.Domain;
//using MedAssets.AMS.Business.WorkDistribution;
using MedAssets.AMS.Common;
//using MedAssets.AMS.Web.Controls;
using MedAssets.AMS.Web.Models;
using MedAssets.AMS.Web.Util;
using MedAssets.AMS.Workflow;
//using Microsoft.IdentityModel.Claims;
using StructureMap;
using MedAssets.AMS.Web.ViewModels;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using MedAssets.AMS.Workflow.Rules;
using MedAssets.Aaa.Facilities;
using MedAssets.Aaa.Security;
using MedAssets.AMS.Business.WorkDistribution;
using System.Web.Script.Serialization;
using System.Runtime.Serialization.Json;
  
namespace MedAssets.AMS.Web.WorkflowRules.Controllers
{
    public class RuleController : Controller
    {
        // public int ClientId = 3503;
        public Guid facilityId = new Guid("AA33D4E9-A389-41B4-BE85-A1F7EFF4B37B");
        public const string UserGroupImageUrl = "../../App_Themes/Default/images/userGroup.png";
        public const string UserImageUrl = "../../App_Themes/Default/images/user.png";
  
        private IWorkflowService WorkflowService
        {
            get { return ObjectFactory.GetInstance<IWorkflowService>(); }
        }
        private IUserTreeManager UserTreeManager
        {
            get { return ObjectFactory.GetInstance<IUserTreeManager>(); }
        }
        private UserTree GetUserList(Guid userGroupId)
        {
            return UserTreeManager.GetUserTreeByUserGroup(ClientId, userGroupId, CurrentPrincipal.Identity.IsInternalUser);
        }
        private RuleUtil _ruleUtil = new RuleUtil();
  
        public IAaaPrincipal CurrentPrincipal { get { return System.Web.HttpContext.Current.User.AsAaaPrincipal(); } }
  
        public int ClientId
        {
            get { return CurrentPrincipal.Identity.ClientId; }
        }
  
        public Guid FacilityId
        {
            get { return CurrentPrincipal.Identity.HomeFacilityId; }
        }
  
        private UserTree UserTreeModel
        {
            get
            {
                var userTree = (UserTree)Session["UserTreeModel"];
                if (userTree == null)
                {
                    userTree = ObjectFactory.GetInstance<IUserTreeManager>().GetUserTree(ClientId, ((AaaClaimsIdentity)CurrentPrincipal.Identity).IsAmsInternal());
                    UserTreeModel = userTree;
                }
  
                return userTree;
            }
            set
            {
                Session["UserTreeModel"] = value;
            }
        }
        public ActionResult About()
        {
            var principal = ObjectFactory.GetInstance<IAaaPrincipal>();
            var clientId = principal.Identity.ClientId;
            var facilityId = principal.Identity.HomeFacilityId;
            var ut = UserTreeModel;
            // var values = WorkflowService.GetRuleSourceObjects().ToList();
            return View("RuleObject");
        }
  
        [AcceptVerbs(HttpVerbs.Get)]
        public JsonResult AlphaSplitUsers(Guid userGroupId)
        {
            var dataContext = UserTreeModel.Children.Where(e => e.QueueId == userGroupId).FirstOrDefault();
            var userTree = GetUserList(dataContext.Id).Children;
            var Users = from t in userTree
                        select new
                        {
                            id = t.QueueId,
                            Name = t.Name,
                        };
            return Json(Users, JsonRequestBehavior.AllowGet);
        }
  
  
        public JsonResult Users(Guid? id)
        {
            var dataContext = UserTreeModel;
            if (id == null)
            {
                var parentusers = from e in dataContext.Children
                                  select new
                                  {
                                      id = e.QueueId,
                                      Name = e.Name,
                                      ImageUrl = e.IsUserGroup ? UserGroupImageUrl : UserImageUrl,
                                      ToolTip = e.IsUser ? e.ContactInfo : null,
                                      hasChildren = e.Children.Any()
                                  };
                return Json(parentusers, JsonRequestBehavior.AllowGet);
            }
            else
            {
  
                var users = dataContext.Children.Where(e => e.QueueId == id).FirstOrDefault().Children;
                var childUsers = from t in users
                                 select new
                                 {
                                     id = t.QueueId,
                                     Name = t.Name,
                                     ImageUrl = t.IsUser ? UserGroupImageUrl : UserImageUrl,
                                     //hasChildren = t.Children.Any()
                                 };
                return Json(childUsers, JsonRequestBehavior.AllowGet);
            }
  
  
  
        }
  
  
        public ActionResult Add()
        {
            return null;
        }
  
        [AcceptVerbs(HttpVerbs.Post)]
      // public ActionResult Save(RuleModel RuleData)
        public ActionResult Save(string sdata)
        {
  
  
            var t = sdata;
           
            
           // var data = RuleData;
            return null;
        }
  
        [AllowAnonymous]
        [HttpGet]
        public ActionResult Get()
        {
            RulesViewModel Rule = _ruleUtil.GetRulesViewModel();
            return View("CreateRule", Rule);
  
            
        }
  
        [AllowAnonymous]
        [HttpGet]
        public ActionResult Create()
        {
            CreateRuleViewModel objRuleViewModel = new CreateRuleViewModel();
            RulesViewModel Rule = _ruleUtil.GetRulesViewModel();
            objRuleViewModel.RulesViewModel = Rule;
            return View("RuleObject", objRuleViewModel);
        }
  
        public ActionResult GetCascadeOperators(string property)
        {
  
            string context = string.Empty;
            string attr = string.Empty;
            string[] tProperty;
            if (!String.IsNullOrEmpty(property))
            {
                //context = property.Substring(property.LastIndexOf('*'));
                tProperty = property.Split('*');
                if (tProperty.Length != 0)
                {
                    attr = tProperty[0];
                    context = tProperty[1];
                }
            }
            List<PropertyOperatorModel> operators = null;
            if (!string.IsNullOrEmpty(attr))
            {
                if (context != "3")
                {
                    operators = _ruleUtil.GetRulePropertyOperator(int.Parse(attr));
                }
                else
                {
                    operators = _ruleUtil.GetRulePropertyForBothContext();
                }
            }
  
            return Json(operators, JsonRequestBehavior.AllowGet);
  
        }
  
        [HttpGet]
        public JsonResult GetAttributeValues(int? id, string facilityIds)
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();
            List<ClientFacilityModel> lstSelected = jss.Deserialize<List<ClientFacilityModel>>(facilityIds);
            List<FacilitywiseLookupModel> attributeLookup = new List<FacilitywiseLookupModel>();
            attributeLookup = GetObjectPropertyLookup(id.Value, lstSelected).ToList();
            var attr = from e in attributeLookup                      
                       where(e.FacId != null)
                       select new
                       {
                           id = e.FacId,
                           Name = e.FaceName,
                           items = e.Lookupmodel,
                           hasChildren = e.Lookupmodel.Any(),          
                       }; 
  
            return Json(attr, JsonRequestBehavior.AllowGet);
        }
  
  
        public JsonResult BindRulePartData(RulePartMemberModel objRulePartMember)
        {
  
            var gridData = 1;
            return Json(gridData, JsonRequestBehavior.AllowGet);
        }
  
  
        public ActionResult RuleContext_Read([DataSourceRequest] DataSourceRequest request)
        {
  
            var ddlData = _ruleUtil.GetRuleAccountContext();
            return Json(ddlData.ToDataSourceResult(request));
        }
  
        public ActionResult RuleAttribute_Read([DataSourceRequest] DataSourceRequest request)
        {
  
            var ddlData = _ruleUtil.GetRuleObjectPropertyLookup();
            return Json(ddlData.ToDataSourceResult(request));
        }
  
        public ActionResult RuleCompare_Read([DataSourceRequest] DataSourceRequest request)
        {
  
            var ddlData = _ruleUtil.GetRuleObjectPropertyLookup();
            return Json(ddlData.ToDataSourceResult(request));
        }
  
        public ActionResult CompareContext(bool IsChecked)
        {
            List<SelectListItem> lstContext = new List<SelectListItem>();
            if (!IsChecked)
            {
                lstContext = _ruleUtil.GetRuleAccountContext();
            }
            else
            {
                SelectListItem objSel = new SelectListItem { Text = "Both", Value = "1" };
                lstContext.Add(objSel);
  
            }
  
  
            return Json(lstContext, JsonRequestBehavior.AllowGet);
        }
  
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult RulePart_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<RulesViewModel> attribute)
        {
            var results = new List<RulesViewModel>();
            if (attribute != null && ModelState.IsValid)
            {
                foreach (var attr in attribute)
                {
  
                    results.Add(attr);
                }
            }
  
            return Json(results.ToDataSourceResult(request, ModelState));
        }
        public IEnumerable<FacilitywiseLookupModel> GetObjectPropertyLookup(int id, List<ClientFacilityModel> faclist)
        {
            IEnumerable<FacilitywiseLookupModel> _lookup = default(IEnumerable<FacilitywiseLookupModel>);
            switch (id)
            {
                case 1:
                    _lookup = PopulateFacilities();
                    break;
                case 2:
                    break;
                case 3:
                    _lookup = PopulatePhysicians(faclist);
                    break;
                case 4:
                case 5:
                    _lookup = PopulatePlanType(faclist);       //Primary Insurance Plan Type
                    break;
                case 6:
                    _lookup = PopulateVisitTypesForSelectedFacilities(faclist);
                    break;
                case 7:
                    _lookup = PopulatePatientTypesForSelectedFacilities(faclist);
                    break;
                case 8:
                    _lookup = PopulateServiceTypesForSelectedFacilities(faclist);
                    break;
                case 9:
                    _lookup = PopulatePatientLocationssForSelectedFacilities(faclist);
                    break;
                case 10:
                    _lookup = PopulatePatientStatusesForSelectedFacilities(faclist);
                    break;
                case 11:
                    _lookup = PopulateFinancialClassesForSelectedFacilities(faclist);
                    break;
                case 12:
                case 13:
                case 15:
                case 16:
                    _lookup = PopulatePlans(faclist);      //Primary Insurance Plan
                    break;
                case 14:
                    _lookup = PopulatePayors(faclist);
                    break;
            }
            return _lookup;
        }
        public IEnumerable<FacilitywiseLookupModel> PopulatePhysicians(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            List<LookupViewModel> PhysicianList = new List<LookupViewModel>();
            var connectionString = ObjectFactory.GetInstance<IResourceLocator>().GetAppDbConnectString(ClientId);
            System.Data.SqlClient.SqlDataReader dr = default(System.Data.SqlClient.SqlDataReader);
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
  
                using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(connectionString))
                {
                    con.Open();
                    using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
                    {
                        cmd.Connection = con;
                        cmd.CommandText = "select (GivenName+(' ')+MiddleName+(' ')+FamilyName) as PhysicianName, PhysicianId from Physician where facilityid=@facilityid";
                        cmd.Parameters.Add("@facilityid", System.Data.SqlDbType.VarChar, 100).Value = facility.FacilityId.ToString();
                        dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            LookupViewModel physician = new LookupViewModel();
                            physician.id = dr["PhysicianId"].ToString();
                            physician.Name = dr["PhysicianName"].ToString();
                            PhysicianList.Add(physician);
                        }
                    }
                    faclkp.FacId = facility.FacilityId;
                    faclkp.FaceName = facility.FacilityName;
                    faclkp.Lookupmodel = PhysicianList;
                    faclkplst.Add(faclkp);
                }
            }
  
            return faclkplst;
  
        }
  
        public IEnumerable<FacilitywiseLookupModel> PopulatePlans(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> planlist = new List<LookupViewModel>();
                var planList = ObjectFactory.GetInstance<IPayorPlanManager>().GetInsurancePlanList(facility.FacilityId);
                faclkp.FacId = facility.FacilityId;
                faclkp.FaceName = facility.FacilityName;
                foreach (var plan in planList)
                {
                    LookupViewModel planmodel = new LookupViewModel();
                    planmodel.id = plan.Id.ToString();
                    planmodel.Name = plan.Description;
                    planlist.Add(planmodel);
                }
                faclkp.Lookupmodel = planlist;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
        public IEnumerable<FacilitywiseLookupModel> PopulatePlanType(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> plantypes = new List<LookupViewModel>();
                foreach (int plantypevalue in Enum.GetValues(typeof(PlanType)))
                {
                    LookupViewModel plantypemodel = new LookupViewModel();
                    plantypemodel.id = plantypevalue.ToString();
                    plantypemodel.Name = Enum.GetName(typeof(PlanType), plantypevalue);
                    plantypes.Add(plantypemodel);
                }
                faclkp.FacId = facility.FacilityId;
                faclkp.FaceName = facility.FacilityName;
                faclkp.Lookupmodel = plantypes;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
  
        public IEnumerable<FacilitywiseLookupModel> PopulatePayors(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                var payorList = ObjectFactory.GetInstance<IPayorPlanManager>().GetPayorList(ClientId).OrderBy(e => e.CompanyName);
                List<LookupViewModel> _payorlist = new List<LookupViewModel>();
                foreach (var payor in payorList)
                {
  
                    LookupViewModel _payor = new LookupViewModel();
                    _payor.id = payor.ClientPayorId.ToString();
                    _payor.Name = payor.CompanyName;
                    _payorlist.Add(_payor);
                }
                faclkp.FacId = facility.FacilityId;
                faclkp.FaceName = facility.FacilityName;
                faclkp.Lookupmodel = _payorlist;
                faclkplst.Add(faclkp);
            }
  
            return faclkplst;
        }
        public IEnumerable<FacilitywiseLookupModel> PopulateFacilities()
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            var facilityService = ObjectFactory.GetInstance<IFacilityService>();
            var facilities = facilityService.GetList(ClientId).ToList().OrderBy(e => e.Name);
            foreach (var facility in facilities)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> facilitylist = new List<LookupViewModel>();
                LookupViewModel _lookup = new LookupViewModel();
                _lookup.id = facility.FacilityId.ToString();
                _lookup.Name = facility.Name;
                facilitylist.Add(_lookup);
                faclkp.Lookupmodel = facilitylist;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
        private ILookupManager _lookupManager;
        private ILookupManager LookupManager
        {
            get { return _lookupManager ?? (_lookupManager = ObjectFactory.GetInstance<ILookupManager>()); }
        }       
        private IEnumerable<FacilitywiseLookupModel> PopulateVisitTypesForSelectedFacilities(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> visityTypes = new List<LookupViewModel>();
                var facGuid = facility.FacilityId;
                var types = LookupManager.GetLookupsForWebAdmin(facGuid, LookupType.VisitType).OrderBy(e => e.Name);
                foreach (var addType in types)
                {
                    LookupViewModel visitTypelookup = new LookupViewModel();
                    visitTypelookup.Name = addType.NameDescription;
                    visitTypelookup.id = addType.Id.ToString();
                    visityTypes.Add(visitTypelookup);
                }
                faclkp.FacId = facility.FacilityId;
                faclkp.FaceName = facility.FacilityName;
                faclkp.Lookupmodel = visityTypes;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
        private IEnumerable<FacilitywiseLookupModel> PopulatePatientTypesForSelectedFacilities(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> patientTypes = new List<LookupViewModel>();
                var facGuid = facility.FacilityId;
                var types = LookupManager.GetLookupsForWebAdmin(facGuid, LookupType.PatientType).OrderBy(e => e.Name);
                foreach (var addType in types)
                {
                    LookupViewModel patientTypelookup = new LookupViewModel();
                    patientTypelookup.Name = addType.NameDescription;
                    patientTypelookup.id = addType.Id.ToString();
                    patientTypes.Add(patientTypelookup);
                }
                faclkp.FacId = facility.FacilityId;
                faclkp.FaceName = facility.FacilityName;
                faclkp.Lookupmodel = patientTypes;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
  
        private IEnumerable<FacilitywiseLookupModel> PopulateServiceTypesForSelectedFacilities(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> serviceTypes = new List<LookupViewModel>();
                var facGuid = facility.FacilityId;
                var types = LookupManager.GetLookupsForWebAdmin(facGuid, LookupType.ServiceType).OrderBy(e => e.Name);
                foreach (var addType in types)
                {
                    LookupViewModel serviceTypeLookup = new LookupViewModel();
                    serviceTypeLookup.Name = addType.NameDescription;
                    serviceTypeLookup.id = addType.Id.ToString();
                    serviceTypes.Add(serviceTypeLookup);
                }
                faclkp.FaceName = facility.FacilityName;
                faclkp.FacId = facility.FacilityId;
                faclkp.Lookupmodel = serviceTypes;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
  
        private IEnumerable<FacilitywiseLookupModel> PopulatePatientLocationssForSelectedFacilities(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> patientLocations = new List<LookupViewModel>();
                var facGuid = facility.FacilityId;
                var types = LookupManager.GetLookupsForWebAdmin(facGuid, LookupType.PatientLocation).OrderBy(e => e.Name);
                foreach (var addType in types)
                {
                    LookupViewModel patientLocationlookup = new LookupViewModel();
                    patientLocationlookup.Name = addType.NameDescription;
                    patientLocationlookup.id = addType.Id.ToString();
                    patientLocations.Add(patientLocationlookup);
                }
                faclkp.FacId = facility.FacilityId;
                faclkp.FaceName = facility.FacilityName;
                faclkp.Lookupmodel = patientLocations;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
  
        private IEnumerable<FacilitywiseLookupModel> PopulatePatientStatusesForSelectedFacilities(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> patientStatuses = new List<LookupViewModel>();
                var facGuid = facility.FacilityId;
                var types = LookupManager.GetLookupsForWebAdmin(facGuid, LookupType.PatientStatus).OrderBy(e => e.Name);
                foreach (var addType in types)
                {
                    LookupViewModel patientStatuslookup = new LookupViewModel();
                    patientStatuslookup.Name = addType.NameDescription;
                    patientStatuslookup.id = addType.Id.ToString();
                    patientStatuses.Add(patientStatuslookup);
                }
                faclkp.FacId = facility.FacilityId;
                faclkp.FaceName = facility.FacilityName;
                faclkp.Lookupmodel = patientStatuses;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
  
        private IEnumerable<FacilitywiseLookupModel> PopulateFinancialClassesForSelectedFacilities(List<ClientFacilityModel> _faclist)
        {
            List<FacilitywiseLookupModel> faclkplst = new List<FacilitywiseLookupModel>();
            foreach (var facility in _faclist)
            {
                FacilitywiseLookupModel faclkp = new FacilitywiseLookupModel();
                List<LookupViewModel> financialClasses = new List<LookupViewModel>();
                var facGuid = facility.FacilityId;
                var types = LookupManager.GetLookupsForWebAdmin(facGuid, LookupType.FinancialClass).OrderBy(e => e.Name);
                foreach (var addType in types)
                {
                    LookupViewModel financialClasslookup = new LookupViewModel();
                    financialClasslookup.Name = addType.NameDescription;
                    financialClasslookup.id = addType.Id.ToString();
                    financialClasses.Add(financialClasslookup);
                }
                faclkp.FacId = facility.FacilityId;
                faclkp.FaceName = facility.FacilityName;
                faclkp.Lookupmodel = financialClasses;
                faclkplst.Add(faclkp);
            }
            return faclkplst;
        }
  
          
  
        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult BindAssignmentGrid(WorkflowRuleActionModel workflowRuleActionModel)
        {
            foreach (var item in workflowRuleActionModel.Activ)
            {
                item.NewActionType = workflowRuleActionModel.ActionType;
                item.NewAssignedUser = workflowRuleActionModel.AssignedUser;
                item.NewAssignedUserId = workflowRuleActionModel.AssignedUserId;
  
            }
            return Json(workflowRuleActionModel.Activ, JsonRequestBehavior.AllowGet);
        }
  
        public ActionResult GetActivities()
        {
            //v//ar act= WorkflowService.geta
            return null;
        }
        public ViewResult GetData()
        {
  
            return null;
        }
  
    }
}
Kris
Top achievements
Rank 1
 answered on 10 Apr 2013
1 answer
73 views
Alright, so here's a point of frustration. We would like to use custom serverPaging and have the parameters passed back, like pageSize, current page, etc. According to the *SPARSE* documentation, it's possible if you just follow this documentation here.

So, the issue we're having is that it doesn't work.

I've created a sample, available here.
Kori
Top achievements
Rank 2
 answered on 09 Apr 2013
2 answers
382 views
Hi,
I'm using Treeview checkboxes with MVVM and SPA. I have a ListView that contains every checked treeview node element ( a copy , to be precise). The Listview shows them with a remove button in a template. When the user click the remove button , the application deletes it from the ListView ( By removing the element from an observable array),  but  , I  have also  to uncheck this element from the TreeView. The ListView is in different View  from the TreeView. In this situation, my problems are these:

1. When I set the "checked" property from the observableHierarchy object to false, the TreeView doesn't reflect the change, using MVVM I thought that the binding was in both ways.

2. Because The TreeView and the ListView are in differents views (or pages), I can't  use something like this
$("#treeview .k-checkbox input").eq(0).attr("checked", false)
In the moment when the remove button is pressed there wont be #treeview element.

3. Using methods that break the MVVM pattern (I save the uid from the li element and use these as selector like in the point 2 ), I can uncheck  the treeview nodes, but , another problem emerges.  Apparently , using Jquery to uncheck  a node doesn't change the datasource , so for kendo even if the node is unchecked , in the datasource  the "checked" property  for that node remains equals true, so when I re-check the node, the "change" event for the observableHierarchy doesn't fire, because the checked value is already "true".

So there is a easy way to acomplish  these?

Baloter
Top achievements
Rank 1
 answered on 09 Apr 2013
3 answers
262 views
Does anyone know how to change the Grid default Css (font-size, height, row-format)?

Thanks for any help.

Mirco 

Dimo
Telerik team
 answered on 09 Apr 2013
3 answers
1.3K+ views
Hi,

I have a very simple requirement of displaying a success message when an item is successfully deleted from the system on the server. In the action result for Destroy command I return the following
return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);

In case of any known error scenario I add a ModelError to the ModelState and catch it in the event.error handler of kendo grid which works fine. But now I need to handle the success and display a user friendly information. I read through the blogs and found that we can use RequestEnd event handler and check for e.type == "remove". I have implemented accordingly, but in no scenarios I get the TYPE property of "e" back with a valid value on it. It always comes back 'undefined'. Following is the snapshot of the grid I use. Please can someone guide if I am going wrong somewhere or missing something. Version of kendo used is 2013.1.319
  <div>
        @(Html.Kendo().Grid<WorkTemplateDto>()
        .Name("Grid1")
        .Columns(columns =>
            {
                columns.Bound(col => col.Column1).Hidden(true);
                columns.Bound(col => col.Column2);
                columns.Bound(col => col.Column3);
                columns.Bound(col => col.Column4).ClientTemplate(@" #=displayhtmlInGrid(Objective)# ");
                columns.Bound(col => col.Column5).Format("{0:dd/MM/yyyy HH:mm:ss}");
                columns.Bound(col => col.Column6);
                columns.Bound(col => col.Column7).Hidden(true);
                columns.Command(command => command.Destroy())
                   .Hidden(true)
                   .IncludeInMenu(false);
                columns.Bound(x => x.Id)
                   .Width(50)
                   .HeaderTemplate(@"<span onclick=""javascript:DisplayDeleteLinksOnGrid();""><img src=""/Content/Images/delete.png"" alt=""Delete"" style=""cursor: pointer;"" /></span>")
                   .IncludeInMenu(false)
                   .Sortable(false)
                   .Groupable(false)
                   .Filterable(false)
                   .ClientTemplate(@"<a class=""k-button-icontext k-grid-delete"" style=""display: none;""><img src=""/Content/Images/delete.png"" alt=""Delete"" /></a>");
            })
        .Groupable()
     .Resizable(resize => resize.Columns(true))
              .Pageable(pages => pages
                                     .PageSizes(true)
                                     .Refresh(true)
              )
        .Sortable()
        .Scrollable()
        .Reorderable(order => order.Columns(true))
        .ColumnMenu(menu => menu.Columns(true))
        .DataSource(datasource => datasource
            .Ajax()
            .Model(model => model.Id(p => p.Id))
            .Events(events => {
                events.Error("griderrorHandler");
                events.RequestEnd("onRequestEnd");
            })
            .Read(action => action.Action("AjaxListSource", "Contoller1"))
            .Destroy(action => action.Action("Delete", "Contoller1"))
        )
        .Selectable(selectable =>
            {
                selectable.Mode(GridSelectionMode.Single);
                selectable.Enabled(true);
                selectable.Type(GridSelectionType.Row);
            }
        )
        .Events(e => {
                e.Change("gridchangeEvent");
            })
    )
    </div>
Rosen
Telerik team
 answered on 09 Apr 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?