We updated APEX to version 21.2.3
We also updated the theme.
In this new version there was a change in the datepicker component.
The problem is that we need to create a mask that inserts the slash that separates the day of the month and the month of the year.
For example: the user wants to enter the date 10/15/2010. When the user types 15 (which is the day), the system inserts the slash "/", that is, the user only inserts the numbers and the system inserts the two slashes.
Before we used javascript to do this, but now it's giving an error and we don't know how to solve it.
Any idea?
My javascript ..
<script language="JavaScript" type="text/javascript">
<!--
function formatar_mascara(src,mascara){
var campo = src.value.length;
var saida = mascara.substring(0,1);
var texto = mascara.substring(campo);
if(texto.substring(0,1) != saida) {
src.value+=texto.substring(0,1);
}
}
//-->
</script>
and the error is ...
Uncaught TypeError: Cannot read properties of null (reading 'length')
at formatar_mascara (f:25:27)
at Object.javascriptFunction (f:166:269)
at Object.da.doAction (desktop_all.min.js:22:5467)
at Object.da.doActions (desktop_all.min.js:22:3909)
at HTMLElement. (desktop_all.min.js:22:2575)
at Function.each (desktop_all.min.js:2:3003)
at S.fn.init.each (desktop_all.min.js:2:1481)
at Object.da.actions (desktop_all.min.js:22:2401)
at HTMLElement. (desktop_all.min.js:22:626)
at HTMLElement.dispatch (desktop_all.min.js:2:43064)
Related
First question:
I want to replace a value in the header. I use --header-HTML header.html for PDF header. For example :
I want to pass 3 values to a PDF:
date
Letter_Number
letter_title
Second question:
Can I use a view for the header? I want to use a view in ASP. For example:
CustomSwitches = "--header-HTML header.cshtml "
About first question
Maybe you could use an HTML page as header, as you actually do, generate new HTML using C# code, and replacing existent HTML file content, with the one you have created, just after generating PDF using Rotativa. The other option I can see, maybe a little bit efficient, because avoids generating all HTML code using C#, is that you use javascript inside your HTML to get this values (not sure if it's completely achievable, since I ignore the origin of the values you mention).
Supposing date value is current date, you could use something like this on your HTML:
<!DOCTYPE html>
<html>
<head>
<script>
function subst() {
var currentDate = new Date();
var dd = String(currentDate.getDate()).padStart(2, '0');
var mm = String(currentDate.getMonth() + 1).padStart(2, '0');
var yyyy = currentDate.getFullYear();
currentDate = dd + '-' + mm + '-' + yyyy;
document.getElementById("dateSpan").innerHTML = currentDate;
}
</script>
</head>
<body onload="subst()">
<div>
Date: <span id="dateSpan"></span>
</div>
</body>
</html>
And on the other side, point to the HTML in custom switches command. Guessing it is located in a folder called PDF, inside Views folder, you could do:
customSwitches = " --header-html " + Server.MapPath("~/Views/PDF/header.html");
I make use of similar code for generating a footer with page number and it works like a charm.
About second question:
I use an MVC action to generate the the partial view that I use as PDF header.
Your code for the custom switches should look like this (using GenerateHeader as action name, PDF as controller and yourModel as the model to be passed to the View, on which you are supposed to store you values):
customSwitches = "--header-html " + Url.Action("GenerateHeader", "PDF", yourModel, Request.Url.Scheme);
For your PDF controller, assuming PdfHeader.cshtml is the view you want to use as PDF header, the code for the action would be as this:
public PartialViewResult GenerateHeader(YourModelType yourModel)
{
return PartialView("PDF/PdfHeader", yourModel);
}
For this PartialView references, remember to include at your controller:
usign System.Web.Mvc;
Hope this helps, if don't, please let me know.
I use fullcalendar in laravel 5.6.
My default view is the month view, and I want to stay on the last view after reloading the page.
example: if I switch to the week view, I want to be able to stay on this view week after refreshing the page and not return to the month view.
Thank you for helping me if you have a solution.
For V5:
var iv = localStorage.getItem("fcDefaultView") || 'timeGridWeek'
var id = localStorage.getItem("fcDefaultDate") || new Date
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: iv,
initialDate: id,
datesSet: function (dateInfo) {
localStorage.setItem("fcDefaultView", dateInfo.view.type);
localStorage.setItem("fcDefaultDate", dateInfo.startStr);
},
})
calendar.render()
It is really simple, just add the following lines to your .fullCalendar initialization:
viewRender: function (view, element) {
// when the view changes, we update our localStorage value with the new view name
localStorage.setItem("fcDefaultView", view.name);
},
defaultView: (localStorage.getItem("fcDefaultView") !== null ? localStorage.getItem("fcDefaultView") : "month"),
Rgds. Senad
use jquery cookie library to store current view using the viewRender event and then use the follwing method to switch to it,
$('#calendar').fullCalendar( 'changeView', 'basicDay' );
here is the reference for viewRender event which is triggered while you switch among views.
https://fullcalendar.io/docs/viewRender
For V4:
viewSkeletonRender: function (view, element) {
// when the view changes, we update our localStorage value with the new view name
localStorage.setItem("fcDefaultView", view.view.type);
},
defaultView: (localStorage.getItem("fcDefaultView") !== null ? localStorage.getItem("fcDefaultView") : "month"),
I had problems with localStorage. For me it only works with localhost, but not on a remote server.
Instead I use ajax and php to store the variable in $_SESSION. Note that the startStr variable returns the first box date, which is the previous month if the first day of the month is not a Sunday. This is corrected for in the php code, by adding 7 days.
Remember to include a session_start(); at the top of your main file.
PHP & Javascript in main file:
var calendarEl = document.getElementById('calendar');
<?php
if(isset($_SESSION['startdate'])) echo "var id = '".$_SESSION['startdate']."';";
else echo "var id = new Date;"
?>
var calendar = new FullCalendar.Calendar(calendarEl, {
initialDate: id,
datesSet: function (dateInfo) {
$.post("./setdate.php", {startdate : dateInfo.startStr}); // posts current view date for storage in $_SESSION
},
.....
PHP code (setdate.php):
<?php
session_start();
$date = strtotime(substr($_POST['startdate'], 0, 10));
$date = strtotime("+7 day", $date); // the datestring relates to the first box, which is usually the previous month, so add a week to get to correct month
$_SESSION['startdate'] = date("Y-m-d", $date);
?>
My example only stores the month, not the view, but the code can easily be extended to include that.
<apex:inputField type="number" value="{!varA}"/>
This is the code varA is defined in the apex controller now the value I want to show of it is 1 only integer but it is displaying 1.00 can you tell me how I can drop that decimal in showing the value?
I tried value={!ROUND(varA)} but its not working
Since you are using inputField to display it, the format is determined by the definition of the custom field varA. Can you change the custom field definition to not specify decimal positions?
Also you can try to use JavaScript for modifying view:
<apex:form id="formBlock">
<apex:inputText value="{!withDec}" id="withDec"/>
</apex:form>
<script>
if('{!withDec}' != '' || '{!withDec}' != null){
var itm = '{!withDec}';
document.getElementById('{!$Component.formBlock.withDec}').value = Math.floor(itm);
}
</script>
Well this is code that is working perfectly like I want to
$("#previous").click(function() {
var month=$("#previous").attr("name");
var loadurl="include/calendar.php?month=january";
$("#calendar").load(loadurl);
return false;
});
Above code simply loads the content from calendar.php exactly I wanted to but when I modified my code to what I actually need the calendar div simply hides display nothing
$("#previous").click(function() {
var month=$("#previous").attr("name");
var loadurl="include/calendar.php?month="+month;
$("#calendar").load(loadurl);
return false;
});
This is the html, $prev_month and $next_month are obtained after some calculations which are January and March respectively for current month(February)
<span class="month"> <?php echo "{$month} {$year}"; ?> </span>
I can't seem to find the problem.
Can you identify the fault here and also Please tell me where I can see jquery error so that I can debug any future problem
I'm very new to MVC and trying to find my way around. I am also coding in VB so having some difficulty there, as most examples are in C#. But I have soldiered on...however, I am currently completely stuck on this one. I have searched for days and tried so many variations, I don't even remember half of them.
This is what I am trying to accomplish: I have a form to enter an employee service action (i.e. onboard, terminate, transfer, etc.). On the form the user will enter a manager first and last name. I need to validate that name against AD and if it is not found, return a dropdown list of possible matches for them to select from.
I'm trying to do this with Ajax and a partial view and have not had good results. Currently I get an error:
There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'Emp_Mgr_Name'
It also is trying to load this when the form initially loads - I don't want it to do this until they have actually entered in the manager name on the form.
Here is what I have so far - where am I going wrong, or is what I'm trying to do not possible and does anyone have any suggestions for how I might accomplish this? Any assistance will be greatly appreciated!
In my main view, these are my script references:
<script src="#Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
And here is the script to validate the manager name and return the list (this is firing and calling the action in my controller):
$("#Emp_Mgr_Last_Name").change
(function ()
{
$.getJSON("/EmpInfo/ValidateMgrName/" + $("#Emp_Mgr_First_Name").attr("value") + "/" + $("#Emp_Mgr_Last_Name").attr("value"),
function (data)
{
$("#ValidateMgrName").html(data)
});
});
Here is the code in my controller (strADList does contain a list of names when this runs):
<HttpGet()>
Public Function ValidateMgrName(ByVal Emp_Mgr_First_Name As String, ByVal Emp_Mgr_Last_Name As String) As ActionResult
Dim strADList As New List(Of String)
If Request.IsAjaxRequest Then
Dim strADInfo = GetADInfo(Emp_Mgr_First_Name.Trim, Emp_Mgr_Last_Name.Trim)
If strADInfo <> String.Empty Then
Else
strADInfo = GetADList(Emp_Mgr_First_Name.Trim, Emp_Mgr_Last_Name.Trim, strADList)
End If
Return Json(New With {.success = True, .data = strADList, JsonRequestBehavior.AllowGet})
End If
End Function
In my main view, here is where I am trying to do the replacement code with the partial view:
<div id="ValidateMgrName">#Html.Partial("ValidateMgrName")</div>
And this is what I have in my partial view:
#Html.DropDownList("Emp_Mgr_Name")