I have a single week fullcalendar on a page containing user schedules by name. I have a text box where a user can enter a username to search by partial stringmatch. My plan was to grab the val() of the textbox, change the {events:"/myfeed"} and refetchEvents if needed. Here is what I did:
$("#username").on("input", function(){
// reload calendar with partial string match of textbox
var username = $("#username").val(); // get the partial username
var thismorninghash = morninghash; // make a copy of the main parameter hash
thismorninghash['events']='/main/feed/user?user=' + username; // change the feed
$("#calendar-am").fullCalendar(thismorninghash);
});
My problem is that I can fetch the new feed but for every character typed, I get a whole new 1 week calendar. I do not get duplicate events in the calendar (as others ask about) I get a brand new calendar. If I type "smith" I get the original plus 5 new calendars. I'm perplexed at this!
Remove existing calendar before load again,
$("#calendar-am").fullCalendar("destroy");
Related
This is probably a longshot, but I'm a teacher working with students on Engineering Design notebooks. One of the main goals/requirements is that each page has a date, and that date shouldn't be editable by students.
I've been looking for scripts that allow me to automate the date in Google Slides, which is where we are building our notebook template.
There are quite a few scripts for updating a date whenever you open a presentation.
does anyone know how to add a script that would update the current date in a text field, only when a new slide is created? EX: Student opens their digital google slides notebook, then they click CTRL+M or right click > New Slide. When the new slide pops up, it autopopulates the date field with the current date, and cannot be edited by the student.
Thanks for any help in pointing me in the right direction.
Yes, you can create a non-editable textbox and later fill it with a timestamp using a script.
The solution below may not meet your whole question, maybe just the first goal, but the idea can be converted into a better script.
A textbox cannot be edited in the slide view if it is placed in a layout in the master view.
To give you the idea, we are going to create a "non-editable" textbox in the main slide layout as an example:
We need to get the Slide id first. From our Google Slides document, take note of its id from its URL format https://docs.google.com/presentation/d/{your slide id}/edit. Use {your slide id} to define the constant SLIDE_ID in your script.
To edit the main layout, we have to enable the Master view from the menu View > Master
In the Master view, we will notice the slides under the "Master" and "Layouts" list. Choose the first layout from the "Layouts" list. The first layout is usually the main slide layout.
In the main slide layout, we create a text box with the text Date. We use the text to find the textbox object id with the following Script 1 first. In the image below, it is the red textbox with the Date text.
Script 1:
const SLIDE_ID = "{your slide id}";
//don't enable the debug log when running this script in production to speed up the processing
const ENABLE_DEBUG_LOG = true;
function findLayoutObjectIdByText_(text) {
var presentation = SlidesApp.openById(SLIDE_ID);
var layouts = presentation.getLayouts(); //layouts[0].getShapes()[0].getObjectId()
layouts.forEach(layout => { // iterate through every layout in the presentation
layout.getShapes().forEach(shape => { // iterate through every shape in the slide
const textStr = shape.getText().asString(); // get shape text string
const textObject = shape; // get shape text object
const matches = textStr.match(text); // find matches
if (matches != null) {
if (ENABLE_DEBUG_LOG) Logger.log("TEXT : " + textStr);
if (ENABLE_DEBUG_LOG) Logger.log("MATCH : " + textObject.getObjectId());
return; //a workaround since we can't use a break statement in forEach() loop
}
});
});
}
function openSlide() {
findLayoutObjectIdByText_(/^Date/g);
}
Select Run > Debug > openSlide. After a few seconds from your script editor, go to View > Logs to see the output for "MATCH". For example, the object id is ga66cd6addf_0_17
Output:
[20-11-01 12:21:09:042 HKT] TEXT : Date
[20-11-01 12:21:09:044 HKT] MATCH : ga66cd6addf_0_17
We can now modify the codes in the openSlide() function in Script 1 as follows:
Modified Script 1:
function openSlide() {
//findLayoutObjectIdByText_(/^Date/g); //comment it out once we are done
var presentation = SlidesApp.openById(SLIDE_ID);
var today = new Date();
var shape = presentation.getPageElementById("ga66cd6addf_0_17").asShape();
if (shape ! null) { //if the shape object present (not being removed)
shape.getText().setText(today.toLocaleDateString('en-US', {day: 'numeric', month: "short", year: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric'}));
}
}
Select Run > Debug > openSlide. After a few seconds, we can see the Date in the textbox has been changed to a proper timestamp in our Google Slides document as follows:
Now, we can use the modified openSlide() function as a time-driven trigger (if the script scope is in the Google Slides document) or as an event trigger (if the script scope is in Google Form or Google Sheet) to keep updating the text. The timestamp textbox cannot be modified when we are not in the master view.
It is not necessary to create a new slide using a script, but you can refer to https://developers.google.com/slides/how-tos/create-slide.
The important thing is to make sure to edit every layout in the "Layouts" list in the Master view with the above idea. Every time the student creates a new slide from the Google Slides document, the new slide will automatically retrieve the assigned slide layout (most likely it is the third Layout in the Master view) that you have included in the timestamp textbox.
Next idea: the above steps can be turned into a whole script if you want to but I will not cover how it can be done here.
Caveat: Since every new slide uses the assigned default slide layout, we are going to see the same timestamp value for all newly created slides. Maybe it is better to run a script that is executed from a Google Form's onSubmit() scope trigger where the student submits his/her attendance for every session, for example. Once submitted, the script will duplicate a Google Slides document for the student from the master/template Google Slides document that has included the "Date" textbox in the layout and timestamps the "Date" textbox in the duplicated document (like the concept of mailmerge/document bookmarks in the Microsoft Word). The script will only act upon the duplicate but not the master/template. The link to this duplicated Google Slides document can be provided from a response email or from a Web redirect. You can include the student's name in this duplicate document as well! So, every student will have his/her own Google Slides document with a different current timestamp each time it is created.
See the merge concept in https://developers.google.com/slides/how-tos/merge
Note: we still cannot avoid the students from modifying the layouts in the Master view when we give them the edit permission.
I have a popup with kendo grid inside that displays records, the first column is
col.Bound(m => m.RecordDate)
.EditorTemplateName("DateTime")
.Width(180).Format("{0:dd/MM/yyyy h:mm tt}");`
This is the DateTime in EditorTemplate -
#(Html.Kendo().DateTimePickerFor(m => m)
.HtmlAttributes(new { data_bind = dataBind}))`
The problem is when I go to that view, and create a record let's say current datetime is 19/10/2017 8:30 AM when i save the record it get's the correct time, the grid is reloaded but the popup is not being closed and then let's say 3 minutes have passed, and I create a record again but the datetimepicker's default value is still 19/10/2017 8:30 AM, instead of 19/10/2017 8:33 AM
Since the window is not being closed then the binded dateTime to the datePicker will allways the be the dateTime that was binded the first time the window was loaded. The element doesn't refresh and there isn't any configuration for it to always get the current DateTime since it is not possible.
If for example you open any window and until your save a couple of minutes have passed the value of the dateTime will again be wrong. If you want the absolute moment of the save you can't give it to the user to insert it or alter it. You should set it at the save event at that exact moment that the save occurs
If however you still want to allow the user to handle that dateTime one way I can think of is to reset the dateTimePicker value to Date.now() every time the user focuses to the window. Obviously you will still have the issue of the time passing while the user inserts his data...
I've a razor view that shows some jobs data on the basis of some filter like date, description, city, country etc. etc. Data loads in grid and then user can open that specific job.
when user clicks to view some job, it redirects on another page. what I want is that when user comes back on this page again, it should have preserved selected filter and searched data accordingly. I tried tempdata but is of no use. Then i tried cookies but it does not allow me to keep object as it always wants a string as a value.
Any guesses please?
Just use the browser local storage and some javascript code before sending the query to your server.
In the event that trigger the query, just collect the data and store it like this with javascript:
function myFunctionToBeCallBeforeSendingTheQuery() {
var query = {
jobTitle: 'user typed text goes here',
countryId: 'the id goes here'
}
localStorage.setItem('query', query);
}
When the user come back to the page you need to execute the following javascript code after the page get loaded:
$(function() {
var query = localStorage.getItem('query');
if(query != null) {
// here you set the fields of your form with the preview stored data.
}
});
I had a question that was marked as a duplicate but it really didn't answer my question, but it did answer another question that I had so that was great :) I think perhaps I did not explain myself correctly so going to try again. Please keep in mind that I am still relatively new to RoR. My previous question can be found here:
Rails: Select on 1 field returns value to another field
So, let me explain what I am trying to achieve again. I have a table called plans and a table called plan_prices. A plan has many plan prices. I have another table called contracts. A contract can have a plan and a plan price, so the contract table has plan_id and plan_price_id. So here is what I am trying to achieve. When I create a contract I have a select for the plan which returns the plan_id. I also have a select on the plan_price that returns the plan_price_id. This first select has some JS on it to determine when it changes so that the plan_price is filtered accordingly. All this is working just fine. The final piece that I want to do is when I select the plan_price there is a column on that table called price. I want to take this price and default it into the contract.price field which can then be changed if the user deems necessary. I am just having a hard time working out how I would default the plan_price.price value into the contract.price field once the plan_price has been selected. The contract.price field is a simple free entry field and not a select field, since the user can change the price to something else.
Hope the above is clear and I hope that there is someone that can help me out on this.
TIA.
Send an Ajax request on the onchange state of the plan_price field:
:onchange=>"selectPrize(this)"
You will be passing the selected value as a param on your AJAX request
JS Function
function selectPrize(prizeID) {
var dataString ='prize='+prizeID.value;
$.ajax({
type: "GET",
url: "/your_controller/your_controller_method",
data: dataString
});
return false;
};
On your controller, in the selected method, look for the plan prize with the id you got through your ajax request.
#plan_prize = Planprize.where("id = #{params[:prize]}").first
Then create a js.erb file in your folder, depending on the method you've chosen in your controller and do some simple javascript to change the value of the contract_prize:
your_method.js.erb file
$(document.getElementById('contract_prize').value = '<%= #plan_prize.prize %>');
This should work.
I have a Telerik grid in my asp.net mvc application that looks something like:
Now it lists all the regions in a zone selected from the list placed just above the grid. zoneid is foreign key in the grid. Now I want that when I add new region in the grid the zoneID should be taken from the list instead of what is present in zone column of the grid because that value is just to display the zone and that can also be removed from the grid as it as apparent from the list which zone the listed regions belong to.
I understand that I could have used editor templates to show this list inside the grid on edit but I prefer it to be outside the grid and provide some filtering on basis of the zone as we are likely to have many regions per zone. so my concern here, now, is how can I set ZoneID of a region (edited or newly added) equal to selected value of list that shows just above the grid control.
When you click on the AddNewRecord button, why don't you set the Value of your zone equals to the zoneId selected in the combobox value ?
I've done something a little similar, but I had to get the value from a Treeview.
private void btnAddContact_Click(object sender, EventArgs e)
{
Int64 companyId = Int64.Parse(treeCompany.SelectedNode.Name);
dsSociete.ContactRow newContact = dsSociete.Contact.NewContactRow();
newContact.SocieteId = societeId;
dsSociete.Contact.AddContactRow(newContact);
}
And once i add a new Contact, it gets automatically its Company (Societe is Company in French) set.
I did it in Winform, but I guess you can do the same in Web?
I solved this problem by hooking the onSave event of Telerik grid like
<%
Html.Telerkik.Grid<xyz.company>()
.Name("name")
.// other properties
.Events(even=>even.onSave("onSave")
.Render();%>
Inside onSave event handler in JS I have written something like
function onSave(e)
{
var data = e.values;
data["companyID"] = $("#CompanySelectList").val();
e.values = data;
return true;
}
onSave event adds the companyID at companyID index of json that will be submitted to the server and modelbinder will bind it with concerning property name of model.