Posts

Donate

How To Disable Cascade Down Selection Of jsTree Child Nodes On Page Load

Hello, I'm currently working on a JavaScript Library jsTree that mimics the behavior and UI of a TreeView control in .NET. One of the issue that's bothering me was to disable the cascade down selection of jsTree Child Nodes On page load if a parent node is selected. The solution is to set the three_state attribute to false and cascade to empty or 'up as presented in the code below. $( '#TreeRoles' ).jstree({ 'checkbox' : { keep_selected_style: false , three_state: false , cascade: 'up' }, 'plugins' : [ "defaults" , "checkbox" ] });

How To Calculate Due Days Excluding Weekends In C#.NET

Here's a function that will calculate the number of days excluding weekends. The parameters passed are the priority which contains number of days and the current date. Sample priorities are 'High[1 day]', 'Average [2 days]' and 'Low [5 days]'. The function then uses Regex to extract the whole numbers from the priority string to be used for incrementing the number of days. public DateTime RecalculateDueDate( string priority, DateTime Today) { int days; int count; DateTime dueDate; count = 0; dueDate = Today; days = int .Parse(Regex.Replace(priority, "[^0-9]" , "" )); while (count < days) { dueDate = dueDate.AddDays(1); if (( int )dueDate.DayOfWeek != 0 && ( int )dueDate.DayOfWeek != 6) count++; } return dueDate; } Source Code: How To Calculate Due Days Excluding Weekends In C#.NET

Check If T-SQL Field Value Is A UniqueIndentifier In Select Case Statement

In the event that you need to check a T-SQL field value if it's a GUID or UniqueIdentifier, the same procedure is used in applying the logic in a where clause. SELECT CartObjectID, CartName, CartQuantity, CASE When TDD.FieldData like REPLACE ( '00000000-0000-0000-0000-000000000000' , '0' , '[0-9a-fA-F]' ) Then ( Select CartValue From tblCartList where ListID = TDD.FieldData ) ELSE TDD.FieldData END As FieldData

Bootstrap Table Column Width And Word-Break Not Working Using Data-Width Attribute

Hello All, One of the issue that I had with Bootstrap Tables by Wenzhixin is that you can't set the width directly using data-width attribute given the code below. <th data-field= "description" data-sortable= "true" data-searchable= "true" data-width= "350px" > Description </th> After doing some research and experiments, the solution that worked for me is to set the Bootstrap Table table-layout style to fixed. Bootstrap Table CSS #tblEmployeeDependents { table-layout : fixed ; } And use data-class attribute instead of data-width property to set the column width. HTML Code <th data-field= "description" data-sortable= "true" data-searchable= "true" data-class= "tdDescription" > Description </th> Data-Class CSS Style .tdDescription { width : 350px ; word - break : break - word; }

Bootstrap Modal Black Background Not Closing After Form Is Submitted

Hello fellow developers! Normally, when closing a Bootstrap Modal, the black background also disappear. However, if the closing of Bootstrap Modal is triggered by a close or button event fired from a "Yes" button of jQuery UI dialog the bootstrap dialog is closed but the black background of the bootstrap modal is still visible. The solution that I came up with is to close the modal dialog before the call to submit the form in the Yes callback function of the jQuery UI Dialog. function fnOpenNormalDialog($form) { var form = $form; $( '<div id="divConfirm"></div>' ).dialog({ resizable: false , modal: false , title: "Confirm Shipping" , height: 150, width: 350, open: function () { $( this ).html( "Confirm that this part is ready to be shipped?" ); }, buttons: { "Yes" : function () { $( this ).dialog( 'close' ); Callback( true , form); }, "No" : function () {

How To Set Or Position BlockUI On Top Of jQuery UI Dialog

Good day! I have this requirement to show an overlay message using BlockUI on top of a jQuery UI Dialog. Assuming that these two are modals, I can't show the progress message on top of the jQuery UI Dialog. I found the solution in stackoverflow that is to set the z-index of BlockUI to 2000. $.blockUI({ message: '<h3>Saving of record in progress...</h3>' , baseZ: 2000 });

Restrict Remote Validation In ASP.NET MVC Edit Mode.

Hello, In data entry operations, we normally validate user input if they exist in the database, if yes we throw some kind of exception or error message that the data they entered already exists in the database. But in scenario like editing of existing information, we don't want this to happen. So to restrict the remote validation in ASP.NET MVC, I found the fix from stack Remote validation restrict for edit controller method but modified the logic in the controller which is to return a JSON rather than a bool value. The code modifications are as follows. Edit View or Edit Partial View: Add another HiddenField for Initial Product Code used for Comparison. @Html.Hidden("InitProductCode", Model.ProductCode) Model: Add AdditionalFields in Remote Attribute. [Display(Name = "Product Code")] [Required(ErrorMessage = "ProductCode is required")] [Remote("CheckProductCode", "Products", HttpMethod = "POST", ErrorMessage = &q

Bootstrap Modal Hide Not Working On Form Submit In ASP.NET MVC

Good afternoon! I'm working on a ASP.NET MVC which uses the oldest version of Bootstrap which 3.0. Normally when working with modals, the hide() function works if using updated versions of the Bootstrap given the code below. The snippet should close the modal after a form has been submitted but this doesn't work as expected when working with the oldest version. $( "#modal-add" ).on( "submit" , "#form-add" , function (e) { e.preventDefault(); var form = $( this ); $.ajax({ url: form.attr( "action" ), method: form.attr( "method" ), data: form.serialize(), success: function (data) { $( "#modal-add" ).modal( 'hide' ); //close modal function $( "#tblEmployee" ).bootstrapTable( 'load' , data); showAlert( 'Saving of record successful!' , 'success' ); }, error: function (er) { showAlert( 'Error saving record. Please try again later.' , 'dan

How To Sort Dates With Invalid Values In JavaScript

Given the sorting function below to sort dates, this doesn't add checking for invalid date values. In return, the sorting doesn't do any effect on the data provided. var DateSortWithValidation = function (a, b) { var dateA = new Date(a); var dateB = new Date(b); if (dateA < dateB) return -1; if (dateA > dateB) return 1; return 0; }; So I made a little modification to the function using isNan() for date validation which sorts the dates properly. var DateSortWithValidation = function (a, b) { var dateA = new Date(a); var dateB = new Date(b); if (isNaN(dateA)) { return 1; } else if (isNaN(dateB)) { return -1 } else { if (dateA < dateB) return -1; else if (dateA > dateB) return 1; else return 0; } }; Usage of the function. $(document).ready( function () { var dates = [ new Date( '08/25/2018' ), new Date( 'test' ), new Date( '09/15/2018' ), new Date( &#

Bootstrap-Table-Export.js Not Exporting Bootstrap Table Data

Normally, exporting a Bootstrap-Table by Wenzhixin using Bootstrap-Table-Export.js plugin works. But in my case, it's returning an empty document whether Excel,CSV, XML or JSON format. I did some debugging on the plugin itself and found out that it doesn't export if the main table contains child table(s). A fix that I came up was to remove the child tables from the table object before passing it to the tableExport.js plugin. The solutions is applied in the doExport() function of Bootstrap-Table-Export.js plugin. doExport = function () { //remove child table elements. var length = that.$tableBody.children( 'table' ).find( 'table' ).length; if (length > 0) { that.$tableBody.children( 'table' ).find( 'table' ).remove(); } that.$el.tableExport($.extend({}, that.options.exportOptions, { type: type, escape: false })); };

Donate