How to show and edit/bind input=date on a live view page? - datetime

In a model I have a field
filed :my_dt, :naive_datetime
As far as I've found out, in Phoenix there's no Html helper for a date alone which will generate a calendar picker. Therefore, I'm using an html tag for it, and it's on a LiveView page:
<input type="date" name="my_model[my_dt]" value={#my_dt_without_time} />
That is, the time part should always remain 00:00 -- may be ignored, for now. I don't need a time zone either, the UTC should be used.
How will I properly bind a my_dt to the date tag such that
a) it'll show itself properly, whenever my_dt is present in the DB; and
b) it'll get edited and updated properly too
?
I'm aware that it'll require pre-formatting it on backend and post-processing, and this will be ok.

Related

Vertical Resource View: custom HTML resources and time slot clicks

Researching https://fullcalendar.io/docs/vertical-resource-view for work
It seems the columnHeaderHtml callback does not work for this view.
https://github.com/fullcalendar/fullcalendar-scheduler/issues/429
Is this still the case? Any way around this?
I also need the ability to click a timeslot. Eg. clicking the 10 AM row to create an event at 10 AM. Does this functionality exist? I can't seem to find any callbacks that seem to work.
My codepen so far:
https://codepen.io/anon/pen/OKyvGZ?editors=0010
EDIT: #ADyson pointed out that columnHeaderHtml only works for date headers, not resource headers as is the case here.

JQuery Mobile Date picker not showing date in Chrome

I have an MVC 4 site using JQuery Mobile. I'm using a model with an EditorFor to render the date editor. in MVC I have this:
#Html.EditorFor(Function(model) model.ActionDate)
The model property is defined as:
<Required>
<RegularExpression("\d{2}/\d{2}/\d{4}", ErrorMessage:="Please enter a date in the format of MM/DD/YY")>
<DataType(DataType.Date)>
<DisplayFormat(ApplyFormatInEditMode:=True, DataFormatString:="MM/dd/yyyy")>
<Display(Name:="Action Date")>
Public Property ActionDate As Date
It renders HTML with the value of:
<input type="date" ... value="04/24/2013" />
But what shows to the user is this:
The date isn't visible to the user, and the 4/24/2013 is not the default of Chrome's date picker. How do I get chrome to actually show the date?
Thanks.
According to the W3C, the value passed to an <input type="date"> element should be in RFC3339 format. This is a specific profile of ISO8601.
In other words, you need to pass the value in yyyy-MM-dd format.
Just hit this exact same problem.
My solution was to avoid the type="date" problem by changing the type to text when I connect the datepicker:
$('#Date').removeAttr('type').attr('type', 'text').datepicker();
If you are not using JQueryUI, just drop the datePicker part.
As I also needed to force the default date format (again thanks to Chrome) it was:
$('#Date').removeAttr('type').attr('type', 'text').datepicker({ dateFormat: 'dd/mm/yy' });
Chrome is now biting us regularly with jQueryUI issues and has gone from being our favourite dev browser to our most troublesome (for compatibility issues).

Printing a "tag" with a barcode using reporting services and DB values in asp.net

Edit 7 : I finally made it! Posted the answer.
Edit 6 : I scrapped the CSS and div and used a reporting services. Look at edits down the post to see where I am at right now.
I'm at a complete lost right now.
Sorry if I am not clear enough with my question, I can edit it to add information if needed. I'll try giving as much info as possible.
I've searched on google for hours now and havn't find anything to help me.
I am trying to create multiple "tag" using information on a user I have in my database and putting them on a page to print them. Plus, I need only 1 tag per page.
I got a stored proc that returns to me the username, name and family name as well as an ID I use to generate a barcode for every users in a certain event.
CREATE PROCEDURE Schema.GetAllTags
#IdEvent int
AS
BEGIN
SELECT Mem.Nom, Mem.Prenom, Mem.Pseudo, Use.IdUser
FROM Schema.User Use
JOIN Schema.Member Mem ON Use.IdMember = Mem.IdMember
WHERE Use.IdEvent = #IdEvent
END
The barcode is generated by calling an asp page and giving it the ID I received from my stored proc in the page parameter. The asp page is an image that I use to show my barcode in other pages.
I tried making the tags using divs, CSS, asp content and all that stuff and it worked... except for the printing part. The tag being resized all the time, the margin not being an inch even tho I tried everything to make it 25.4mm (1 inch) and on top of it, the url of the page always showing in the preview print. All thoses problem could be solved by the client simply from unchecking the show url and setting the margin yourself in the options. But I don't want to force the client to do theses in order to fix the problem. I want it to be 3 by 2 in, with 1 in margin and no url without having to change printing options.
I was told using reporting services would solve my printing problems. But I have no clues how to make what I need out of reporting services (I know what reporting services are mind you)... even less on how to get my barcode in there.
Here what the tag should look like in the end on a print page. 3in x 2in with 1in margin on top and left when printing.
Here the CSS I used to try and print my tag :
<style type="text/css">
#page
{
margin: 25.4mm 25.4mm 25.4mm 25.4mm;
}
#media print
{
body *
{
visibility:hidden;
}
#tagPrint, #tagPrint *
{
visibility:visible;
}
#tagPrint
{
position:fixed;
top: 0px;
left: 0px;
}
#NOPRINT
{
display:none;
}
}
And here the asp (That is for my page with only 1 tag showing) :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<div id="tag" class="formRow">
<div id="tagPrint" style="border:1px solid;width:76.2mm;height:50.8mm">
<p style="text-align:center" />
<br />
<asp:Label ID="lblUserTag" runat="server" style="font-weight:bold;font-size:18px" />
<br />
<asp:Label ID="lblFullNameTag" runat="server" style="font-weight:bold;font-size:16px" />
<br />
<br />
<asp:Image ID="imgBarcodeTag" runat="server" />
<br />
<asp:Label ID="lblIdTag" runat="server" style="font-weight:bold;font-size:16px" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Currently generating my tags using a repeater on my page to generate multiple tags and binding the dataset.tables[0].Rows to the repeater. Allowing me to create thoses tags.
Is there any ways to do it without reporting services using only javascript and CSS?
Is it doable with reporting services (Using an asp page in a reporting service to make a barcode)? Since my barcode come from a font, is there any other way then adding the font on the compiter in order to use it in reporting services? (I don't want the client to have to install the font) Would making a pdf of the tag easier/better?
Edit : Started working around with a report service.
Right now I got the report made with 4 parameter. (Username, full name, barcode url and the ID)
I'll give update on what happens next.
Edit 2 : So... after managing to make a report service and showing it in the page. I can't seem to get my image to show on the report. And even if I did. I don't know how to make multiple page on the report or how to print it.
I decided to try making my Div Tag in PDF instead and try to print it that way. I'll update tomorrow when I get the chance to try it.
Edit 3 : Aside from wanting to smash my head on a wall several times, I tried doing it in PDF and it's not working. Found out it can probably be done in flash, but I do not want to do it in flash. So I'm back to the report service.
I made a report service with a grid where I send my dataset to the grid and put the datas in each fields. I installed the font to be able to use it in the report. Now I can't seem to bind my dataset to the report. I tried an SqlDataSource and ObjectDataSource and nothing seems to work. I started another report in a new project to try from scrap. Maybe something from my current project is playing against me.
I'm about to give up. -_-
Edit 4 : I finally made it to get something working. Got my report on my page working just fine.
Now only thing I have left to do... is manage to get the report to have multiple page.
Edit 5 : Rereading my edits and I realized I forgot to say that slightly after edit 2, I scrapped the parameters stuff and used a dataset instead. Also, I scrapped everything about CSS and the div to use a reporting service to save a PDF file of the tags.
So let me just preface this with a bit of explanation about SSRS: You're doing it all wrong.
By that I mean, if you're just trying to embed your ASP code and output in SSRS to achieve graphical fidelity, it's not going to happen.
The reason SSRS was recommended to you is because it can take a set of data and reproduce it with high graphic fidelity in a variety of reporting styles, formats, and output methods.
But you have to build it from scratch. No HTML, no CSS, no ASP, no .Net (well .. sort of. For you, yes, no .Net required.)
Whoa, whoa, whoa, where you going? It's not that hard, I promise.
So ... first, let's just set up a task list for you to do this in SSRS. Before we can even do that, let's just build a wizard-driven report so we can get your ID tag data set into the report. It'll give you a basic feel for how SSRS consumes data and turns it into a report.
Create a brand-new Reporting Services project.
Add a new report to this project. In the Solution Explorer, right click on the Reports folder and "Add New Report."
Step one is select the data source. Hook it up to your database with the stored procedure you're running, test your connection, moving on.
Next step is to Design the Query - but you've already done that with your Sproc, so just paste that in - for now, add a hardcoded value for your IdEvent. We'll fix that later.
Now choose your report type - let's just do Tabular for now. Matrix is more for lots of row/column dynamics, and you're just looking for a simple printable report, so table for you.
Now in designing the table, just add all of your output columns to the Detils group.
Choose any old Table style, you're throwing this all away in the end.
Name your report something useful and finish.
Now you've got a RDL, it's got a data source, a data set, and some code in the designer area. You can preview what you've done so far by clicking the "Preview" tab in the designer area. Pretty sweet, there's all your data, in little rows in a table. Now what?
Now for the task list. Start Googling, you can learn all of this, it won't take too long, and when you're done, you'll have a well-formatted set of ID tags ready for the printer. And if you run into specific issues - well, that's what this site is for, right?
Create a parameter to pass in your IDEvent to your stored procedure.
Insert a dynamic external image into the row that retrieves the barcode from your ASP page. (Hint: read up on using "Expressions" in SSRS.)
Figure out how to use the page break options in SSRS to only print 1 tag per page.
Use the properties window to format each "row" of your table to look like your tag.
Figure out whether to export your report as a PDF, or just use the MHTML version provided.
You might also potentially want to learn how to embed an SSRS report in a .Net application (how are you clients printing the tags, anyway?) And of course there are tons of little methods, properties, and aspects of SSRS that are out of scope for this particular task but might be worth at least taking a look at for later projects.
Good luck!
Finally! I made it!
Here what I did.
Made a SSRS.
Made a report viewer and ObjectDataBinder
Create a DataSet for the SSRS using my stored proc.
Bound the report viewer to the SSRS.
Play around the SSRS to place the fields like they need to be placed.
Set page margin in SSRS to 1 inch. Set the report to 3x2 inch.
Set the report size to 5x4 inch.
Tested and enjoyed my victory over theses hours of frustration.
Note : It took me lot of time because visual studio bugged on me and I had to delete and redo my SSRS entirely.
Result :
A beautiful PDF file with perfect size, margin that print perfectly WITH a codebar. VICTORY!

Adding Refresh Tag to View

I need a view to refresh automatically every 20 seconds, and have added the following code to the view header via the views GUI - with no success. The code (or portions of it) are simply displayed on the view and no updating is performed. I've tried omitting both and just the ending ?php statement. If someone can tell me the proper code to use, or a better approach at updating the view automatically, I'd be very appreciative. Thanks.
print "<meta http-equiv=\"refresh\" content = \"20\" />;
There are a few modules that can take care of this for you via AJAX without refreshing the page.
This should take care of everything for you: http://drupal.org/project/ajax_views_refresh
Be sure to get the main AJAX module as the base.
A more complex one, if you want to code a bit: http://drupal.org/project/live_update
If you want to just refresh nodes and the view is on them you can do the old school refresh with this... http://drupal.org/project/refresh
Your code isn't coming through, but if it's php code make sure that the input format for the view header is set to "PHP Code"
Read the fine print under the text area. Sometimes PHP Code format doesn't require <?php tags. Some modules implement this differently.
Use drupal_set_html_head
For example:
drupal_set_html_head('<meta http-equiv="refresh" content = "20" />');

ASP.NET 3.5 - Making a field readonly/unmodifiable without "disabling" it

I have a web application with a form that has disabled fields in it. It allows a "Save As" function which basically means the settings can be copied into a new configuration (without being modified) and in the new configuration they can be changed to something else. The problem I am running into with this is that since the fields are disabled, they are not getting posted through and do not appear in the context object on the server side.
When I removed the logic to disable the fields, that part works fine. So the remaining problem is, how to "disable" the fields (not allow any change of the data in any of the entry fields) without really "disabling" them (so that the data gets posted through when saving)?
I was originally looking for a way to do this in CSS but not sure if it exists. The best solution is of course, the simplest one. Thanks in advance!
(Note: by 'disabled' I mean "The textboxes display but none of the text inside of them can be modified at all". It does not matter to me whether the cursor appears when you click inside it, though if I had a preference it would be no cursor...)
http://www.w3schools.com/TAGS/att_input_readonly.asp
readonly attribute is what you want.
i would suggest that instead of using the non-updateable field values from the page's inputs, you retrieve the original object from the DB and copy them from there. It's pretty trivial using something like Firebug to modify the contents of the page whose form will be posted back to modify the values, even if they are marked as readonly. Since you really want the values from the original, I would simply reget the object and copy them. Then you don't need to worry about whether the original (and non-updateable) properties get posted back at all.

Resources