kendo ASP.NET MVC specific multiselect in Gantt Edit - kendo-asp.net-mvc

I am a new user of kendo and I have a problem with a gantt!
I have a page with a Gantt kendo. For each activity I have a button edit. When my popup edit is open I have lot of fields and a multiselect. This multiselect should be specific for each activity.
I have put the code below in my function edit Gantt :
$.get('/Activity/ReadMultiSelectActivities?initiativeId=' + #Model.ID + '&excludeSectorId=' + $('#SectorID').val() + "&activityID=" + e.task.id, function (data, status) {
allActivitiesDataSource = new kendo.data.DataSource({
data: data.Data,
group: { field: "SectorName" },
sort: { field: "ActivityNumberString", dir: "asc" }
});
});
var msLinkedActivities = $('#linkedActivities').data('kendoMultiSelect');
msLinkedActivities.setDataSource(allActivitiesDataSource);
My problem is that I get the impression that my code is read into account with a delay time. That is, if I click on edit activity 1 the first time the list is empty, I close the edit and then return to edit activity 1 the list is filled. If then I go on edit activity 2 it will be the list of activity 1 ...
I tried many things that I view on tuto, demo and forum telerik but nothings function!
Have you an Idea for fix this problem please?

For information I have resolve my probelm. This is because the data are long to retrieve and so it made the setDataSource before loading the data!

Related

How to remember past searches for anonymous users

My application doesn't have user accounts, the users anonymously interact with it.
I want to be able to remember what a user has searched for previously without attaching it to their account (as they don't have one). How would I go about doing this?
Is cookies the answer I am looking for? If so, can you point me in the right direction.
Clarification: when the users clicks the search bar to search for something, I want to be able to display what that specific user has searched for in the past in a drop-down box.
you can use localStorage in this situation
There are code snippets which will help you (preliminarily add jQuery in you project for example in head of html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
). Just add it in your templates
//selector by id - #selector, by class - .selector, by tag - selector
function getItemsFromLS(){
return JSON.parse(localStorage.getItem('search'))
}
function addNewItemToLS(item){
localStorage.setItem('search',JSON.stringify([...getItemsFromLS(), item]))
}
$(document).ready(function(){
//if there are no storage create it
if(!localStorage.getItem('search')){
localStorage.setItem('search', JSON.stringify([]))
}
//click on the search button
$('search-button-selector').click(function(){
//get item form input
let newItem = $('input-type-selector').val()
addNewItemToLS(newItem)
})
//show items on focus of search bar
$('input-type-selector').focus(function(){
let searchItems = []
$(this).change(function(){
searchItems = getItemsFromLS().filter((item)=>item.includes($(this).val()))
$('list-of-search').empty()
searchItems.forEach((item)=>{
$('list-of-search').append(`<span>${item}</span>`)
})
})
})
})

Unchecking checkbox in oracle apex

Created an report with checkbox using apex_item and when checked more than one check box i will display alert message "not to check more than one checkbox with ok button " after clicking ok it should be unchecked . please find my JavaScript code that displays alert message
if($("input[type=checkbox]:checked").length > 1)
{
var msg = alert('You are not allowed to select more than one employee');
}
It's best to use the APEX JavaScript APIs for this type of thing. You can find them here: https://apex.oracle.com/jsapi
If you're getting started with JavaScript and APEX, you may find these slides useful: https://www.slideshare.net/DanielMcGhan/getting-started-with-javascript-for-apex-developers
Here's a solution that should work for you (just change the name of the item to match yours):
var cbItem = apex.item('P1_CHECKBOX');
if (cbItem.getValue().length > 1) {
alert('You are not allowed to select more than one employee');
cbItem.setValue(); // Passing nothing to clear the value
}

How to make People Picker column Read only in SharePoint 2013

I am trying to make people picker column in my list edit form "Read-only". I found many solutions that worked on SharePoint 2010 but couldn't find a reliable solution for SharePoint 2013/Office 365.
It would be great if someone can point me to a good solution.
To make People picker readonly, you can use the below JQuery code:
$(".sp-peoplepicker-delImage").css({ 'display' : 'none'});
$(".sp-peoplepicker-editorInput").css({ 'display' : 'none'});
You can also apply them with the help of css:
<style>
.sp-peoplepicker-delImage{
display:none;
}
.sp-peoplepicker-editorInput{
display:none;
}
</style>
This is the easiest and fastest way to make people picker fields read only in SharePoint
2013/online, but it will make every people picker field on the form read only. So please let
me know if you want for a specific column.
Since in SharePoint 2013 for rendering List Forms was introduced a new client side rendering engine (called CSR) that is based on JavaScript/HTML i would recommend the following approach. To customize edit form in order to render People Picker in edit form using display mode as explained below.
Steps
1) Create a JavaScript template for rendering People Picker in display mode:
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
Templates: {
Fields: {
"AssignedTo": {
EditForm: renderAssignedTo
}
}
}
});
});
function renderAssignedTo(ctx) {
var item = ctx['CurrentItem'];
var userField = item[ctx.CurrentFieldSchema.Name];
var fieldValue = "";
for (var i = 0; i < userField.length; i++) {
fieldValue += userField[i].EntityData.SPUserID + SPClientTemplates.Utility.UserLookupDelimitString + userField[i].DisplayText;
if ((i + 1) != userField.length) {
fieldValue += SPClientTemplates.Utility.UserLookupDelimitString
}
}
ctx["CurrentFieldValue"] = fieldValue;
return SPFieldUserMulti_Display(ctx);
}
2)Open Edit Form page in edit mode
3)Place Script Editor web part on the page and insert the specified template by enclosing it using script tag
That's it.
Result
ยจ

How to dynamically change the list data when click on picker 'done' button in Sencha Touch

I am developing my application in Sencha touch. In that I have a list and Picker and I want to update the list data dynamically when selecting the picker i.e., I want to add data to list dynamically when tap on 'Done' button of Picker. I used some logic for this but this doesn't update the list content.
listeners: {
change: function(picker,value) {
textValue = picker.getValue()['name'];
var me = this,
nameList = this.down('#namesList');
nameList.add({fullname:textValue}) ;
}
}
When I update like this, it throws me the error that 'Uncaught TypeError: Cannot call method 'add' of null' eventhough 'namesList' is already defined. Please show me the way to solve this problem.
I would add a record to the data/store of the list, and then capture the list and refresh.
The issue there is that nameList isnt actually the list component.
Try adding for example an id to the list, and then in the picker change listener:
Ext.getCmp('mylist-id').refresh()
Hope it helps.

How do I utilize the save event in a Sitecore custom Item Editor?

I am creating a custom item editor, and am using the following blog post as a reference for responding to the "save" event in the Content Editor, so that I do not need to create a second, confusing Save button for my users.
http://www.markvanaalst.com/sitecore/creating-a-item-editor/
I am able to save my values to the item, but the values in the normal Content tab are also being saved, overriding my values. I have confirmed this via Firebug. Is there a way to prevent this, or to ensure my save is always after the default save?
I have this in as a support ticket and on SDN as well, but wondering what the SO community can come up with.
Thanks!
Took a shot at an iframe-based solution, which uses an IFrame field to read and save the values being entered in my item editor. It needs to be cleaned up a bit, and feels like an interface hack, but it seems to be working at the moment.
In my item editor:
jQuery(function () {
var parentScForm = window.parent.scForm;
parentScForm.myItemEditor = window;
});
function myGetValue(field) {
var values = [];
jQuery('#myForm input[#name="' + field + '"]:checked').each(function () {
values.push(jQuery(this).val());
});
var value = values.join('|');
return value;
}
In my Iframe field:
function scGetFrameValue() {
var parentScForm = window.parent.scForm;
if (typeof (parentScForm.myItemEditor) != "undefined") {
if (typeof (parentScForm.myItemEditor.myGetValue) != "undefined") {
return parentScForm.myItemEditor.myGetValue("myLists");
}
}
return null;
}
In theory, I could have multiple fields on the item which are "delegated" to the item editor in this way -- working with the content editor save rather than trying to fight against it. I'm a little uneasy about "hitchhiking" onto the scForm to communicate between my pages -- might consult with our resident Javascript hacker on a better method.
Any comments on the solution?
EDIT: Blogged more about this solution