I have a problem and I searched many hours and I did not find useful information on the internet.I have 7 widgets in my website.These widgets are defined as DockPanel. I want user to drop any panel in any zones on my page will save the location.But I have to get dockpanel names to send my database through my webmethod. I try all combination to get my widget names, and I failed.Please help me to solve this issue.
https://docs.devexpress.com/AspNet/js-ASPxClientDockManager.GetPanels
https://docs.devexpress.com/AspNet/js-ASPxClientControlCollection.GetByName(name)
https://documentation.devexpress.com/AspNet/9448/Common-Concepts/Client-Side-Functionality/Client-Side-Events
https://documentation.devexpress.com/AspNet/9150/ASP-NET-MVC-Extensions/Common-Concepts/Client-Side-API
https://www.devexpress.com/Support/Center/Question/Details/T202401/how-to-find-dockpanel-on-the-client-using-javascript
I tried this solution but I did not fix the issue.
getName = function () {
var results = widgetName.exec((this).Object.toString());
var myJSON = JSON.stringify(results);
// return (myJSON && myJSON.length > 1) ? myJSON[1] : "";
return myJSON;
};
it is my minimal getname funtion.I try to convert panelname to object after that turn to string.How can I fix this?
When I run console.log in inspect window,I see everytime undefined or null or one letter.How can I fix this?
All 'widgets' are nothing but Objects and all objects have 'Attributes', the name, id, or whatever, are attributes.
So, try this:
var x = document.getElementsByTagName("Panel")[0].getAttribute("name");
Console.log(x);
Or if you use JQuery:
var x = $("#Panel").data("name");
Related
I am working with the org.graalvm.polyglot script engine in my Java11 project to evaluate a JavaScript.
The script to be evaluated returns a JavaScript array with two entries.
...
var result={};
result.isValid=false;
result.errorMessage = new Array();
result.errorMessage[0]='Somehing go wrong!';
result.errorMessage[1]='Somehingelse go wrong!';
....
In my java code I try to evaluate the result object:
Value resultValue = context.getBindings(languageId).getMember("result");
In my Eclipse Debugger I can see that I receive a PolyglotMap containing the expected values:
I can iterate over that map to get the values with a code like this:
...
try {
mapResult = resultValue.as(Map.class);
} catch (ClassCastException | IllegalStateException | PolyglotException e) {
logger.warning("Unable to convert result object");
return null;
}
Iterator it = mapResult.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next();
String itemName = pair.getKey().toString();
Object itemObject = pair.getValue();
...
In this way I am able to extract the boolean 'isValid'. But with the object 'errorMessage' I struggle.
Inspecting the Object again within the Eclipse Debugger it looks like this:
If I test this object it is an instanceOf Map. But I am unable to get any of the values out of this object.
Can anybody help me to understand what exactly this object represents and how I can extract the both values 'Someting go wrong!' and 'Sometingelse go wrong!' ?
When I iterate over this second map it seems to be empty - even if the debugger shows me the correct values.
I'm not 100% sure why as(Map.class) behaves that way, it might be worth creating an issue on github to figure it out: github.com/oracle/graal
But if you access the values using the API without converting to a Map it would work as you expect:
var errorMessage = resultValue.getMember("errorMessage");
errorMessage.hasArrayElements(); // true
var _0th = errorMessage.getArrayElement(0);
var _1th = errorMessage.getArrayElement(1);
You can also convert the polyglotMap to Value and then do it:
val errorMessage = context.asValue(itemObject);
errorMessage.hasArrayElements(); // true
errorMessage.getArrayElement(0);
PolyglotMap of course has the get method. And the Value javadoc says that:
Map.class is supported if the value has Value.hasHashEntries() hash entries}, members or array elements. The returned map can be safely cast to Map. For value with members the key type is String. For value with array elements the key type is Long.
Can you try getting them with the Long keys?
There might be something obvious I'm missing, so in any case it's better to raise an issue on GitHub.
I am practicing making an e-commerce site. I am struggling passing my javascript variable between the shopping cart page to the checkout page. I tried following this example:
page one:
<a href="example2.html?myVar1=42&myVar2=66" >LINK</a>
page 2:
var qs = new Querystring();
var v1 = qs.get("myVar1");
var v2 = qs.get("myVar2");
I could not get it to work because my webpage threw an error about not recognizing QueryString, so I am currently trying like this by using window.localStorage as follows:
Page 01:
<button class="checkout" type="button" onClick="window.location.href='checkout.html'; window.localStorage.setItem("total",total)">Checkout</button>
Page 2:
var name = window.localStorage.getItem("total");
Currently, I am throwing a console.log(total) on the 2nd page but it returns "null" each time. Any idea why it's not catching the value from the first page? Please help.
If you have suggestions or a solution for either method, it would be much appreciated. I feel like I'm really close with the 2nd method, I may just be missing something on the page 1 portion, thanks in advance.
To fix your first method (passing variables between pages via a query string), you'd probably want something like:
// page one:
<a href="example2.html?myVar1=42&myVar2=66" >LINK</a>
// page 2:
var query = window.location.search;
if( typeof query !== 'undefined' ) {
var params = {},
parts
;
// take off the ? and split into groups of key=value strings
query = query.replace('?','').split('&');
// split key=value strings into a usable object
for(var i=0;i<query.length;i++){
parts = query[i].split('=');
params[ parts[0] ] = parts[1];
}
// now access your variables like so:
params.myVar1 // is now "42" (a string)
params.myVar2 // "66"
}
I am setting an attribute called "bikes" in the session, which is a List.
For instance, this code prints the firt element of the list :
function affiche() {
var myString = "${bikes.get(0).getName()}";
alert(myString);
}
I would like to use for instance a for loop and use something like
"${bikes.get(i).getName()}";
but I don't find a way to do it.
Any ideas ?
Thank you by advance
EDIT : with a java page, i am doing
session.setAttribute("bikes", bikes);
the only way I found to access the List in my jsp page is to do something like
var st = "$bikes";
but this gives something like [(filePathToObjectPackage#543622), (filePathToObjectPackage#54328)]. I think those numbers are related to memory. I can be wrong, but i thought the only way to access an object inside that list was to do
var myString = "${bikes.get(0).getName()}";
If so, i would like to be able to call it for a number contained in a variable.
I hope this is clearer now ...
Do you have try in this way:
function affiche() {
var myString = "";
for (var i = 0; i < bikes.length; i ++ ){
myString = "${bikes.get(i).getName()}";
alert(myString);
}
}
I am new to radcontrols.
I want to know how to get type of control of a radcontrol using javascript.
For normal asp.net controls we write:
var controlType=document.getElementById("hdnCode").type;
The above code will give type of control as "hidden", and for textbox it will give "text".
When i try to get type of a rad control it gives undefined as shown here:
var controlType=document.getElementById("RadComboBox1").type;
The above code gives undefined.
Please suggest me how to get type in case of Rad Controls.
Thanks
You can't really check for the type of the control like this, these are complex objects (IScriptControls) and not simple HTML elements.
You can try the following approach to see the instances of given type (the if block shows how you can make a check only):
function get_allRadCombos()
{
var allRadCombos = [];
var allRadControls = $telerik.radControls;
// all RadControls are referenced
for (var i = 0; i < allRadControls.length; i++)
{
var element = allRadControls[i];
if (Telerik.Web.UI.RadComboBox && Telerik.Web.UI.RadComboBox.isInstanceOfType(element))
{
allRadCombos.push(element);
}
}
// only the RadCombos are gathered into an array
return allRadCombos;
}
The $telerik.radControls is an array the RadControls create and populate, you can check a given instance by referencing it through the $find(controlClientID) method
I'm writing a jquery-plugin, that changes a css-value of certain elements on certain user-actions.
On other actions the css-value should be reseted to their initial value.
As I found no way to get the initial css-values back, I just created an array that stores all initial values in the beginning.
I did this with:
var initialCSSValue = new Array()
quite in the beginning of my plugin and later, in some kind of setup-loop where all my elements get accessed I used
initialCSSValue[$(this)] = parseInt($(this).css('<CSS-attribute>'));
This works very fine in Firefox.
However, I just found out, that IE (even v8) has problems with accessing the certain value again using
initialCSSValue[$(this)]
somewhere else in the code. I think this is due to the fact, that I use an object ($(this)) as a variable-name.
Is there a way arround this problem?
Thank you
Use $(this).data()
At first I was going to suggest using a combination of the ID and the attribute name, but every object might not have an ID. Instead, use the jQuery Data functions to attach the information directly to the element for easy, unique, access.
Do something like this (Where <CSS-attribute> is replaced with the css attribute name):
$(this).data('initial-<CSS-attribute>', parseInt( $(this).css('<CSS-attribute>') ) );
Then you can access it again like this:
$(this).data('initial-<CSS-attribute>');
Alternate way using data:
In your plugin, you could make a little helper function like this, if you wanted to avoid too much data usage:
var saveCSS = function (el, css_attribute ) {
var data = $(el).data('initial-css');
if(!data) data = {};
data[css_attribute] = $(el).css(css_attribute);
$(el).data('initial-css', data);
}
var readCSS = function (el, css_attribute) {
var data = $(el).data('initial-css');
if(data && data[css_attribute])
return data[css_attribute];
else
return "";
}
Indexing an array with a jQuery object seems fishy. I'd use the ID of the object to key the array.
initialCSSValue[$(this).attr("id")] = parseInt...
Oh please, don't do that... :)
Write some CSS and use the addClass and removeClass - it leaves the styles untouched afterwards.
if anybody wants to see the plugin in action, see it here:
http://www.sj-wien.at/leopoldstadt/zeug/marcel/slidlabel/jsproblem.html