Requirement:
Need to pass tablename and columnname to the sql hint using code mirror at runtime.
Problem Faced:
Column names are passed dynamically ,where table name doesn't.
Code:
function initAutoComplete(tablename) {
alert(tablename);
var tmptables= {
tabledata:["a","b"]
}
CodeMirror.commands.autocomplete = function (cmeditor) {
CodeMirror.showHint(cmeditor,'', {
completeSingle: false,
tables: tmptables
});
}
}
Expected is systemset.columnname
var content={"AAAAAAAA": ["test"]};
function initAutoComplete() {
CodeMirror.commands.autocomplete = function (cmeditor) {
CodeMirror.showHint(cmeditor,'', {
completeSingle: false,
tables: getcontent()
});
}
}
function getcontent(){
return content;
}
Related
I am using bootstrap table to display my data. I used a data formatter on a column like:
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' id='yqBdItemList[" + index + "].price' name='yqBdItemList[%s].price' value='%s'>", index, value);
return html;
}
then using jquery to set value,but it's not working :
$('#yqBdItemList[0].price').val('1111')
if i use updateCell or updateRow, the select2 column will invalid
good
not woring
bootstrap-table onLoadSuccess function:
function onLoadSuccess(data) {
$.fn.select2.defaults.set("theme", "bootstrap");
$("select.form-control").each(function () {
$(this).select2().on("change", function () {
const data = JSON.parse($(this).select2('val'))
console.log(data)
// $(this).valid();
})
})
$(".check-box").each(function () {
$(this).iCheck({
checkboxClass: 'icheckbox-blue'
})
})
}
the onLoadSuccess will invalid after updateCell or updateRow
I have a condition column == 1 and if this is the case, the function MakeCellsEditable and the function myCallbackFunction are initialized:
<script src="https://raw.githubusercontent.com/ejbeaty/CellEdit/master/js/dataTables.cellEdit.js"></script>
$(document).ready(function () {
var table = $('#myTable').DataTable();
$('#myTable tbody').on('mousedown', 'td', function () {
$('#myTable').data('column', table.cell(this).index().columnVisible);
});
if (column == 1) {
table.MakeCellsEditable({
"onUpdate": myCallbackFunction
});
}
});
function myCallbackFunction(updatedCell, updatedRow, oldValue) {
var array = updatedRow.data();
var id = array[0];
var column = $('#myTable').data('column');
console.log("The column is: " + column);
jQuery.ajax({
type: "POST",
url: "update.php",
data: {
updatedCell: updatedCell.data(),
id: id,
column: column,
},
cache: false
});
}
What I want to do is, after the functions are executed, I want to kill them. Because otherwise if I one time clicked column 1, then all my tables are editable (not only column 1).
I tried table.unbind(); or table.die(), but this didn't work out.
I tested at the end of the code:
function destroyTable() {
if ($.fn.DataTable.isDataTable('#myTable')) {
table.destroy();
table.MakeCellsEditable("destroy");
}
}
But it didn't work out
To answer the question in the headline: Yep:
function thiswilljustworkonce(){
alert("once");
this.thiswilljustworkonce=function(){};
}
thiswilljustworkonce();
thiswilljustworkonce();
Use columns option for CellEdit plugin to specify which column needs to be editable. There would be no need to remove event handler.
var table = $('#example').DataTable();
function myCallbackFunction (updatedCell, updatedRow, oldValue) {
console.log("The new value for the cell is: " + updatedCell.data());
console.log("The values for each cell in that row are: " + updatedRow.data());
}
table.MakeCellsEditable({
"columns": [0],
"onUpdate": myCallbackFunction,
"confirmationButton": true
});
See this example for code and demonstration.
I'm using code I found online to convert a standard option set field to a checkbox in MS CRM 2015 online. It keeps giving me the above error.
Here is the code:
function MultiPickList3(param1, param2, param3,param4,param5)
{
try
{
var fn = arguments.callee.toString().match(/function\s+([^\s\(]+)/);
if (param1==null || param2==null)
{
alert("Error: Parameter missing. \n Format: <optionset fieldname> , <option value text field> , [<option header>], [<select color>] , [<deselect color>] , \n ["+"Function="+fn[1]+"]" );
return true;
}
var tparamtype=Xrm.Page.data.entity.attributes.get(param1).getAttributeType();
if (tparamtype!="optionset")
{ alert (param1+"(first parameter) should be of type optionset \n"+"[function="+fn[1]+"]");
return true;
}
var tparamtype=Xrm.Page.data.entity.attributes.get(param2).getAttributeType();
if (tparamtype!="memo")
{ alert (param2+"(second parameter) should be of type memo (text with mutiline) \n[function="+fn[1]+"]");
return true;
}
var plOptions=param1;
var plText=param2;
var plMenuItem="View Selected List";
var SelectedList_orig = crmForm.all[plText];
var FullList=crmForm.all[plOptions];
var SelCtr=-1;
var new_selColor="orange";
var new_deSelColor="white";
if (param4!=null)
new_selColor=param4;
if (param5!=null)
new_deSelColor=param5;
var SelectedList =SelectedList_orig.value.split("\r\n");
crmForm.all[plText].style.display="none";
if(FullList!=null && SelectedList!=null)
{
initColor();
if (param3!=null && param3!="")
{
plMenuItem=param3;
}
else
{
plMenuItem=FullList.options[0].text;
changeColor("grey",0);
}
for (var ctr=0; ctr<SelectedList.length;ctr++)
{
selCtr=SelectedIndex(SelectedList[ctr]);
if (selCtr >-1)
{
changeColor(new_selColor,selCtr);
}
}
}
function SelectedIndex(selectedText)
{
var FullListText;
for (var ctr1=0; ctr1<FullList.options.length;ctr1++)
{
FullListText=FullList.options[ctr1].text;
if ( FullListText==selectedText)
{
return ctr1;
}
}
return -2;
}
crmForm.all[plOptions].attachEvent('onchange', OnChangePL);
function OnChangePL()
{
var SelCtr=-1;
var sel=crmForm.all[plOptions].SelectedText;
if (sel==plMenuItem)
return;
SelCtr=SelectedIndex(sel);
var SelColor="grey";
SelColor=crmForm.all[plOptions][SelCtr].style.backgroundColor;
if (SelColor==new_selColor)
{
changeColor(new_deSelColor,SelCtr);
saveChanges(sel,selCtr,"del");
}
else
{
changeColor(new_selColor, SelCtr);
saveChanges(sel,selCtr,"add");
}
}
function saveChanges(p_selText,p_SelCtr,p_mode)
{
switch(p_mode)
{
case "add":
SelectedList.push(p_selText);
break;
case "del":
for (var ctr2=0;ctr2<SelectedList.length;ctr2++)
{
if (SelectedList[ctr2]==p_selText)
{
SelectedList.splice(ctr2,1);
break;
}
}
break;
}
Xrm.Page.getAttribute(plText).setValue(SelectedList.join("\r\n"));
}
function initColor()
{
for (var ctr3=0; ctr3<FullList.options.length;ctr3++)
{ changeColor(new_deSelColor, ctr3); }
}
function changeColor(newColor, newCtr)
{
crmForm.all[plOptions][newCtr].style.backgroundColor=newColor;
}
}
catch (e)
{ alert (e.description);}
}
param2 takes the field "new_textholder" which is a multiline text field. It's defined on the form and I have checked to make sure I am writing it correctly.
What could be the problem?
Thank you!!
This error is likely coming from the crmForm.all[plText] line. I'm guessing your org is recent enough that support for the old 4.0 api is no longer present, which would mean that the all object is no longer available, which would give you that error (plText is set to the value of param2). You might be able to modify this code to work on your 2015 form, but I don't have a 2015 org available to me at the moment so I can't say for sure.
I'm working on a file-upload feature in my MVC 3 application.
I have it working correctly (kinda), the problem is within the onComplete function when I try to remove the qq-uploader class, it gets removed from all the checked table cells.
The workflow would be as follows, user checks multiple check boxes the "upload file" btn appears in each row checked, but once one upload is complete in one row the 'qq-uploader class is removed from all cells not just the cell where the file was uploaded.
The table row cell in question :
#if (Model.ElementAt(index).CertName != null)
{
<td>#Html.DisplayFor(m => Model.ElementAt(index).CertName)</td>
}
else
{
<td id ="attBtn" class="file-uploader-attachment-Class"></td>
}
Script used in view :
<script type="text/javascript">
$(document).ready(function () {
function handleCheckbox() {
if ($(this).find(':checkbox').is(':checked')) {
$(this).find('.file-uploader-attachment-Class').removeClass("upload-placeholder-unchecked");
createUploader($(this));
}
else {
$(this).find('.file-uploader-attachment-Class').addClass("upload-placeholder-unchecked");
$(this).find('.file-uploader-attachment-Class').html($('#myHTML2').html());
}
}
$('tr').each(handleCheckbox);
$('tr').on('click', handleCheckbox);
function createUploader(container) {
var elements = container.find('.file-uploader-attachment-Class');
var CAL_ID = container.find(':checkbox').val()
var row = $(this).parent();
Array.prototype.filter.call(elements, function (element) {
var uploader = new qq.FileUploader({
element: element,
sizeLimit: 2147483647, // max size
action: '/CalibrationViewer/AttachmentUpload',
allowedExtensions: ['xls', 'xlsx', 'pdf', 'doc', 'docx', 'csv', 'txt', 'rtf', 'zip', 'zipx', '7z'],
params: {
customer: CUST_NAME,
calibrationId: CAL_ID
},
multiple: false,
debug: false,
onComplete: function (id, fileName, responseJson) {
alert(responseJson.msg);
$('.qq-uploader').remove();
elements.closest('.file-uploader-attachment-Class').prepend('<div class="uploadedTag"><p>Uploaded</p></div>')
}
});
});
}
});
This worked for me
elements.closest('.file-uploader-attachment-Class').find('.qq-uploader').remove();
I have created an object where i need to assign some variables(parameters) and when the object is called, the variables(parameters) change. Here is my code:
var Modal = {
init: function () {
contact1: "";
contact2: "";
aboutus1: "";
aboutus2: "";
privacy1: "";
privacy2: "";
terms1: "";
terms2: "";
$(".modaltrigger").removeAttr("target");
$(".modaltrigger").click(function () {
if ($(this).is("#contact")) {
$('#primary_url').attr('href', contact1);
$('#secondary_url').attr('href', contact2);
} else if ($(this).is("#aboutus")) {
$('#primary_url').attr('href', aboutus1);
$('#secondary_url').attr('href', aboutus2);
} else if ($(this).is("#termsconditions")) {
$('#primary_url').attr('href', terms1);
$('#secondary_url').attr('href', terms2);
} else if ($(this).is("#privacy")) {
$('#primary_url').attr('href', privacy1);
$('#secondary_url').attr('href', privacy2);
}
});
}
};
I am trying to initialize the object above, and it does not work:
Modal.init(
contact1: "http:www.test1.com";
contact2: "http:www.test2.com";
aboutus1: "http:www.test3.com";
aboutus2: "http:www.test4.com";
privacy1: "http:www.test5.com";
privacy2: "http:www.test6.com";
terms1: "http:www.test7.com";
terms2: "http:www.test8.com"
);
it is Done like this way,
i Guess this is what you want to do.
var Modal = {
init: function (args) {
//then access your values like this
contact1= args.contact1;
contact2 = args.contact2;
..........
.........
.........
}
}
And to initiate this method you have write as
Modal.init({
contact1:"contact str",
contact2:"contact str",
.....
.....
lastitem : "last str"
});