Telerik Forums
Kendo UI for jQuery Forum
1 answer
215 views
Can anyone think of a clean way to make the go back button un-clickable if the user is already on the first page.

Not sure if there is already a hidden setting somewhere that does this...

Using MVC4 if its important.
Petur Subev
Telerik team
 answered on 10 Apr 2013
1 answer
175 views
All the examples in the API use an array of indices for setting this value.
http://docs.kendoui.com/api/dataviz/chart

We are trying to solve the need for positioning a second vertical line in the chart to mark today's date by adding a second vertical axis.  Is it even possible to set the AxisCrossingValues of the category index with an array of dates rather than indices?

Setting axisCrossingValue : [new Date(1/1/2013), new Date()] does not work.

Thanks.
Iliana Dyankova
Telerik team
 answered on 10 Apr 2013
1 answer
219 views
So how would I handle dropdowns in the editor template. Every time my editor template is intialized my selectlist for my dropdowns are null. Do I need to set up an empty list and populate on the dropdown on edit in jquery?

Here is my grid:
@(Html.Kendo()
                          .Grid(Model.Activity.MediaForms)
                          .Name("MediaIterations")
                          .HtmlAttributes(new { @style = "primaryGridStyle" })
                          .Columns(columns =>
                          {
                              columns.Bound(form => form.Date).Format("{0:mm/yyyy}").Title("Month");
                              columns.Bound(form => form.Name).Title("Ad Name");
                              columns.Bound(form => form.TopicDesc).Title("Message Topic");
                              columns.Bound(form => form.TypeDesc).Title("Media Type");
                              columns.Bound(form => form.OutletName).Title("Media Outlet");
                              columns.Bound(form => form.TimesAdRan).Title("Runs");
                              columns.Command(command => { command.Edit(); command.Destroy(); });
                          })
                          .Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("AddEditMediaForm"))
                          .ToolBar(toolbar => toolbar.Create())
                          .DataSource(datasource => datasource
                                                              .Ajax()
                                                              .ServerOperation(false)
                                                              .Model(model => model.Id(form => form.Id))
                                                              .Create(create => create.Action("AddMediaForm", "Form", new { planActivityId = Model.Activity.PlanActivityID }))
                                                              .Destroy(destroy => destroy.Action("DeleteMediaForm", "Form", new { planActivityId = ViewBag.planActivityId }))
                                                              .Update(destroy => destroy.Action("DeleteMediaForm", "Form", new { planActivityId = ViewBag.planActivityId })))
                    )


Here is my editor template in the editortemplates views folder:

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>MediaForm</legend>
        <div>
            <label>Month ads ran @Html.TextBoxFor(model => model.Month, new { @placeHolder = "mm",@columns="2" })/@Html.TextBoxFor(model=>model.Year,new{@placeHolder="yyyy", @columns="4"})</label>
            <label>Ad Name @Html.TextBoxFor(model => model.Name)</label>
        </div>
        <div>
            <label>
                Message Topic
                <select id="MediaTopic" name="TopicId">
                    @foreach (var category in Model.MediaCategoriesList)
                    { 
                        <optgroup label="@category.CategoryDesc">
                            @foreach (var topic in category.TopicsList)
                            {
                                
                                <option value="@topic.Value" selected="@topic.Selected">@topic.Text</option>
                            }
                        </optgroup>
                    }

                </select></label>
            <label>Ad Runs @Html.TextBoxFor(model=>model.TimesAdRan)</label>
        </div>
        <div>
            <label>Media Type @Html.DropDownListFor(model => model.TypeId, Model.TypeList, new { @id = "mediaTypes" })</label>
        </div>
        <div>
            <label>Media Outlet @Html.DropDownListFor(model=>model.OutletID,Model.OutletList)</label>
        </div>
    </fieldset>
}
if I don't set the dropdown intially in my view all my dropdownlist are null and produce an exception. Is there anyway around this.
Vladimir Iliev
Telerik team
 answered on 10 Apr 2013
5 answers
270 views
Dear Telerik Gurus,

Good morning.

I just downloaded the a trial version of KendoUI and saw the Popup editing features. Would just like to inquire if we customize the layout of the modal window something like as seen below:

http://www.flickr.com/photos/32177697@N03/8516958999/

Can that be done using a template in the  popup edit template?

Thanks in advance and more power to Telerik :D

regards,
almond
Almond
Top achievements
Rank 1
 answered on 10 Apr 2013
3 answers
869 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
159 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
953 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
157 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
372 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
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
MultiColumnComboBox
Chat
DateRangePicker
Dialog
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Effects
Accessibility
PivotGridV2
ScrollView
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Breadcrumb
Collapsible
Localization
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
TimePicker
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?