I'm trying to get GridLookup selected value,
#Html.DevExpress().GridLookup(settingsGrid =>
{
settingsGrid.Name = "CommandeDetailEnCours.Compte";
settingsGrid.KeyFieldName = "Numero";
[...]
}).BindList(Model.ListeComptes).Bind(Model.CommandeDetailEnCours.Compte).GetHtml()
The question is: How I can get Value because in javascript
"CommandeDetailEnCours.Compte".GetGridView() [...]
not work ?
Use the client-side GetValue method in the following manner.
To retrieve the complex name on the client use the How to use the ClientInstanceName and Name properties when they contain special characters approach.
var lookupClientInstance = ASPxClientControl.GetControlCollection().GetByName("CommandeDetailEnCours.Compte");
var value = lookupClientInstance.GetValue();
alert(value);
Related
I am trying to update an object (Generic List object) to RuntimeFiledCollection. When I try to update using the following code, I am getting always Serialization error :(
//My object which need to update set with the documentRuntimeField value
List<docInfo> docInfoList = new List<docInfo>
docInfo = new docInfo { ID = "11233", PageNumber = 1, text ="MyOwnText"};
docInfoList.Add(docInfo);
// Construct DOcument RuntimeFields Collection
var docRunTimeCollection = new CaptureDocumentService.RuntimeFieldCollection();
var docRunTimeField = new CaptureDocumentService.RuntimeField
{ Name = "FieldName", Value = docInfoList };
docRunTimeCollection.Add(docRunTimeField);
captureDocumentServiceClient.UpdateDocumentFieldValues(sessionId, null, validDocumentId, docRunTimeCollection);
I always get sterilization error as shown below. Can someone give me an example how to update document field values with an object. Any help ?
Error : There was an error while trying to serialize parameter http://www.kofax.com/agilityservices/sdk:runtimeFields.InnerException message was System.Collections.Generic.List
For RuntimeField class, you can see the the Value property is of type Object, but that is misleading, because it is not an arbitrary container. It takes the type that you defined for that field in your Extraction Group. But essentially that just means it will take a DateTime for a Date field or numeric types for a Number field, and anything else would be casted to string.
If you actually using a Table Field, then you cannot use the API to set the contents of the entire table. You would instead set the RuntimeField.TableRow and RuntimeField.TableColumn properties to use the API to set individual cells.
I'm trying to set the value of a custom radio button field that has 3 possible options: Yes, No or none. I'm using the Dapplo c# Jira SDK.
I've tried everything going from using "name" to "value" to "id" but nothing seems to work, I always get back "Could not find valid 'id' or 'value' in the Parent Option object".
Note that I want to set the field value by using the ID of the optionset value, not the textual value (like Yes or No) as that might change over time.
These are some of my attempts:
string jsonString = #"{""id"": ""11684""}";
var myJSON = JsonConvert.SerializeObject(jsonString);
issueToCreate.Fields.CustomFields.Add("customfield_12093", jsonString); //When I enter the 'jsonString' variable directly I get the same error.
does anyone have any idea? This seems much harder than it should be..
After trying about everything, the following finally worked:
var optionSetObject = new { id = "11681" };
issueToCreate.Fields.CustomFields.Add("customfield_12093", optionSetObject);
I thought the c# anonymous object wouldn't get serialized correctly, but apparently it does. Make sure the "id" value is a string though! If you enter it as an int, Jira won't recognize it for some reason.
You can try: (like use JavaScriptSerializer to serialise an anonymous object):
var optionSetObject = new { id = "11681" };
var serializer = new JavaScriptSerializer();
var output = serializer.Serialize(optionSetObject);
issueToCreate.Fields.CustomFields.Add("customfield_12093", output);
How I can pass var to function?
I need to create the following unknown data model, and pass it to my function, which shout parse it using RazorRenderer:
var emailData = new {name="value" , name2="value2" ... , nameN="valueN"}
The function can't receive var, so we used object, but then we can't convert it back, and we get an exception when call:
string htmlBody = render.Parse(File.ReadAllText(TemplatePath), emailData );
When I do the following, in same function it works:
var emailData = new { UserRequest = "hello", UserEmail = "name#domain.com" };
string htmlBody = render.Parse(File.ReadAllText(TemplatePath), emailData);
But when try to pass the emailData to the function it not work, any idea?
I can do the rendering out of the function and pass the result to the function, but I thought it may be nice to do it internally inside the function.
BTW- I tried JSON Serialize and Decerialize, with no luck.
If I understand your question correctly, it is not possible. Anonymous type names cannot be represented in user code hence there is no way to make them an input parameter to a function.
Your best bet is to create a type and use that as the return from the query and then pass it into the function. For example,
class YourDataClass {
public string ColumnName;
}
var query = (from name in some.Table
select new YourDataClass { ColumnName = name });
YourMethod(query);
...
YourMethod(IEnumerable<YourData> enumerable);
In this case though, you are only selecting a single field, so it may be easier to just select the field directly. This will cause the query to be typed as an IEnumerable of the field type.
I am assigning property names of a dynamic object as ints in string form. The int value represents an int ID in a database I am using. However I am stuck on how to retrieve the value assigned to the property as shown below:
dynamic test = new ExpandoObject()
IDictionary<string, object> proxyFiler = test as IDictionary<string, object>;
proxyFiler["four"] = 4;
proxyFiler["5"] = 5;
int r = test.four; // Works
int s = test.5; // Doesn't work
A method which reads the database will return an "int" and I would like to be able to access the property value with that property name.
To expand on this: what if I wanted to do a linq query to sort out a list of dynamic objects according to a property name? In this case I need to get the propertyName which I have retrieved as a string e.g. "15":
return disorderedList.OrderBy(o => o.propertyName).ToList();
Does anyone know a simple solution to this problem or do you recommend a different approach? Thanks.
In order for dynamic to work in this way, the key has to follow the rules for valid identifier names in C# (the rules are specified in this outdated MSDN page, but also in the C# language specification). A single number (5) is not an allowed identifier name, which is why that doesn't work.
Note that you can still retrieve the value by using the type as a dictionary, in a similar manner to how you populated it.
As for your second example - you are never using value, so it has no effect. It's the same as just writing int r = test.four;
Edit:
I believe, given your approach, you'd need to cast to a dictionary:
return disorderedList
.OrderBy(o => ((IDictionary<string, object>)o)[propertyName]).ToList();
EPiServer only:
How do I search for pages with any value in a given property? I can do a search for pages with a specific value in the property, but I can't figure out how to search for "not empty".
For example, this doesn't work:
var criterias = newPropertyCriteriaCollection
{
new PropertyCriteria()
{
Condition = CompareCondition.NotEqual,
Name = "MyProperty",
IsNull = false,
Type = PropertyDataType.String,
Value = ""
}
};
var pages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criterias);
An exception is thrown, "The crieria value cannot be null or empty. Set the IsNull property to search for null."
Any ideas?
Yeah, this is confusing. In case anyone else stumbles on this, here's how to search for pages with a certain PageReference property set to something:
new PropertyCriteria()
{
createdCriteria.Name = "MyProperty";
createdCriteria.Type = PropertyDataType.PageReference;
createdCriteria.Condition = EPiServer.Filters.CompareCondition.NotEqual;
createdCriteria.Value = "0";
createdCriteria.IsNull = false;
}
Unless I'm missing a trick, this doesn't appear to be possible using the EPiServer PropertyCriteriaCollection.
I've had a dig around in reflector and here are my findings. The FPWC method eventually calls EPiServer.DataAccess.PropertySearchDB.FastFindPagesWithCriteria().
Within this method is the following:
foreach (PropertyCriteria criteria in criterias)
{
if (criteria.IsNull)
{
criteria.Value = null;
}
else if (string.IsNullOrEmpty(criteria.Value))
{
throw new EPiServerException("The crieria value cannot be null or empty. Set the IsNull property to search for null.");
}
...
}
So its not possible to search for an empty string value, without setting IsNull to true. This is then fed down to the EPiServer.DataAccess.PropertySearchDB.ExecuteCriteria method, which constructs and formats the DB command. Because IsNull is true, the netPropertySearchNull stored proc is used. Searching for a string needs to use the netPropertySearchString stored proc.
if (criteria.IsNull && !PageDB.IsMetaData(criteria.Name))
{
cmd.CommandText = "netPropertySearchNull";
}
My suggestion would be to load the full list of pages and filter using linq. Alternatively you could look into bypassing the API and implementing a direct DB query, or use some of the low level EPiServer data access methods (not recommended)
Apologies for my first answer - I really should test code before posting :)
I've seen something where the page has a a hidden bool property "Property X contains a value" that is set in the Saving event.
Then that bool property is used as a PropertyCriteria instead of the one you are REALLY interested in.
To find empty values you need to specify the IsNull property on the PropertyCriteria and use the Equal compare condition.
E.g
var criterias = newPropertyCriteriaCollection
{
new PropertyCriteria()
{
Condition = CompareCondition.NotEqual,
Name = "MyProperty",
IsNull = true,
Type = PropertyDataType.String
}
};