Posts

Localizer in Controller

Localizer in Controller Using using Microsoft.Extensions. Localization; Includes private readonly IStringLocalizer< AppAccessController>  _localizer; Resource file must be in a Controller Folder in Resources Method example public Dictionary<string,string> GetRoleList(string appName, bool includeX) { //Code here return allItems.ToDictionary<string, string, string>(i => i, i =>  _localizer[i] ); }

Excel download with Jquery using Table

I have a tricky dynamic table built from a model that I did not want to fashion in the controller so wanted to just download the table as shown. This Jquery/Javascript solution allowed me to do just that. Using a button on the page id='export' and using a table on the page id='tblExport' We add an event listener for the button - I have declared everything explicitly but could probably have shortened some references to objects.   //For the Csv Export const toCsv = function (table) { // Query all rows var data = "" ; var tableData = []; var rows = $ ( " table tr " ); rows. each ( function (index, row) { var rowData = []; $ (row). find ( " th , td " ). each ( function (index, column) { rowData. push (column. innerText ); }); tableData. push (rowData. join ( "," )); }); data += tableData. join ( " \n " ); return data; }; const download = function (te

Linq Remove from list based on other table

One way to do it when you have two lists (repYearlyData and otherdata)       foreach (var yd in repYearlyData)             {                 for(int d=0;d<otherdata.Count;d++)                 {                     if (yd.AssignedRep == otherdata[d].AssignedRep)                     {                         otherdata.RemoveAt(d);                     }                 }             } var result = peopleList2 . Where ( p => ! peopleList1 . Any ( p2 => p2 . ID == p . ID ));         public List<TeamAverages> GetRepMonthlyAverages()         {             int tday = DateTime.Now.Day;             int mnth = DateTime.Now.Month;             int yr = DateTime.Now.Year;             var otherdata = (from c in db.calldetail_viw                 join w in db.UserWorkgroups on c.LocalUserId equals w.UserId into workGroups                              from ug in workGroups.Where(w => !w.WorkGroup.Contains("Team")).Where(w => !w.WorkGroup.Conta

Disable Button based on checked items in CheckboxList

Windows Forms using the ClientID                $("#<%=chkMinCedProgramManagers.ClientID %>").find('input[type="checkbox"]').click(function () {                                    $("#<%=btnSaveSubGroup.ClientID %>").removeAttr("disabled");   //Identify How many checkboxes are checked so that we can toggle the button               var prgchecked = $('#<%=chkMinCedProgramManagers.ClientID%>').find('input[type="checkbox"]:checked').length; //Disable button if we have zero checked  if (prgchecked===0) {                         $("#<%=btnSaveSubGroup.ClientID %>").attr("disabled", "disabled");  };                });

Sparkline Chart

VIEW <script src="~/scripts/jquery.sparkline.min.js"></script> <div style="border:2px solid #cccccc;padding:10px;width:50%; box-shadow: 10px 10px 5px #888888;text-align:center;float:left;">             <h4 style="color:#58B609;">Expirations by Month next 12 months</h4><hr />             <div class="sparkline" data-type="bar" data-width="97%" data-height="250px" data-bar-Width="12" data-bar-Spacing="10" data-bar-Color="#58B609" style="float:left;margin-left:30px;">                 @ViewBag.Expire              </div>       $(".sparkline").each(function () {                     var $this = $(this);                     $this.sparkline('html', $this.data());                 }); CONTROLLER       public ActionResult Index(int? id, int? reportType)         {             ViewBag.Expire = getExpiring

Multiple Filters

 $(document).ready(function () {     ManageRadioButtons();     numerizeRows();     $('[data-toggle="tooltip"]').tooltip(); }); jQuery.expr[':'].icontains = function (a, i, m) {     return jQuery(a).text().toUpperCase()         .indexOf(m[3].toUpperCase()) >= 0; }; $("#searchInputResponsibility").keyup(function () {     if (checkMultiple() == true) {         filterMultiple();         return true; }     var data = this.value.split(" ");     var currentRow = $("#fbody").find("tr").not('.H').not('.thead');         if (this.value == "") {         currentRow.show();         return;     }     //hide all the rows     currentRow.hide();       currentRow.filter(function (i, v) {     var $t = $(this).find("td:eq(0)");     for (var d = 0; d < data.length; ++d) {         if ($t.is(":icontains('" + data[d] + "')")) {             return true;         }     }     re

Jquery add dynamic numeric column

 Jquery adding column options function numerizeRows() {     var eachRow = $("#fbody").find("tr").not('.H').not('.thead');          var start = 1;     $(".id").each(function() {         this.text(start);         start = start + 1;     });     //eachRow.each(function () {      $(this).children('td:eq(0)').html(start);     //    var myNumber = '<td>' + start + '</td>';     //    this.prepend(start);     //    start = start + 1;     //}); };