I'm using a EntityDataSource with WhereParameters binded from DropDownLists. The Where Clause may be something like this: "it.applicationId = #applicationId" but in that DropDownList i've created a ListItem with Text="All" Value="".
Of course that when the value is "" i don't want to use that value on the query.
How can i do that?
Thank U All
It looks like there is no design time possibility to use parameters optionally.
Try hooking the Selecting event, like it is described in this question.
In your particular case you can get the selected value of the DropDownList (for example, using the FindControl method) and then simply either pass the value of the parameter, or use the query without a Where clause.
you should at first set the attribute "ConvertEmptyStringToNull" in your parameter to true
then type your where condition as follows
"#applicationId IS NULL OR it.applicationId = #applicationId"
Related
I have an event-based rule configured to fire on click of an element with a specific class. On click, I would like to capture the value of a data attribute that exists. The DTM documentation says you can capture attribute values using this syntax:
%this.data-event%
or
%this.id%
Example HTML:
On click of links with the class "test", I would like to store the value of "event name" within an eVar. When I used the above syntax however, the syntax is converted to a string and in the Adobe server call as:
v25:%this.data-event%
What is the best way to dynamically grab the value of an attribute of an HTML element on click within DTM?
DTM documentation says you can do that, but in practice I too have found that it doesn't seem to work as advertised most of the time, and will instead populate it with a literal (un-eval'd) string like that.
So what I do instead is under Conditions > Rule Conditions I create a Custom condition. In the Custom condition, I add the following:
// example to get id
_satellite.setVar('this_id',this.id);
// example to get href
_satellite.setVar('this_href',this.href);
return true;
Basically I create on-the-fly data elements using javascript, and then return true (so the condition doesn't affect the rule from triggering).
Then I use %this_id%, %this_href%, etc. syntax from the data element I created, in the Adobe Analytics section variable fields.
The easist way to capture the values of a data attribute against an eVar or prop on the element clicked using DTM is to set the input as the following:
%this.getAttribute(data-attributename)%
For example, if there was a data attribute on an element of data-social-share-destination='facebook' simply input %this.getAttribute(data-social-share-destination)%. This will then capture the value of 'facebook'
More detail on data attributes can be found at http://www.digitalbalance.com.au/our-blog/event-based-tracking-using-html5-custom-data-attributes/
I found a solution. The best way to grab the value of an attribute on click is to use this syntax:
%this.getAttribute(data-title)%
The key is to not use quotes around the attribute name AND ensure the attribute has a value.
If the attribute is missing, the expression is not replaced by an empty string as one would normally expect from experience in other platforms, but instead will display the raw un-interpolated code.
Is there an easy way to get a default value from an Erlang record definition? Suppose I have something like this:
-record(specialfield, {
raw = <<"default">> :: string()
}).
I would like to have some way to retrieve the default value of the raw field. Something like this would be very simple:
#specialfield.raw % => <<"default">>
This is not possible. I would need to instantiate a record in order to get the default value:
Afield = #specialfield{}
DefaultValue = Afeild#specialfield.raw
DefaultValue % => <<"default">>
Is there an easier way of doing this? I seems like there should be some way to retrieve the default value without having to create an instance of the record.
How about:
raw_default() -> <<"default">>.
-record(specialfield, { raw = raw_default() }).
And now you have a function with the default in it. This will be extremely fast since it is a function call to a constant value. If this is also too slow, enable inlining.
Constructing an empty record and accessing one field can be done on one line:
(#specialfield{})#specialfield.raw.
Take a look at erlang - records, search section "11.8".
There's not much special about records - they're just a tuple at runtime. So to get the field raw from the tuple of default values that is the internal representation of #specialfield{} you would use:
element(#specialfield.raw, #specialfield{}).
In this case, #specialfield.raw is the index of the value for raw in the #specialfield tuple. When you pass in specialfield that resolves to a tuple in the form {specialfield, <<"default">>}.
i need to get data by descending orderby Visidate of patient so i tried url like this
192.168.1.105:33396/FalconCPDataService.svc/DEPhysicians?$format=json&$expand=DEPatientVisits&$orderby=DEPatientVisits/VisitDate+desc
but showing exception
{"odata.error":{"code":"","message":{"lang":"en-US","value":"The parent value for a property access of a property 'VisitDate' is not a single value. Property access can only be applied to a single value."}}}
The reason is that DEPatientVisits is not a single valued navigation property, so it is unable to append a property name to it. If it is a single valued, it works fine, such as:
http://services.odata.org/v4/OData/OData.svc/Products?$expand=Supplier&$orderby=Supplier/Name
Thanks for inviting.
I am not fully understand your question. you want to sort entities in DEPhysicians? or DEPatientVisits?
If you are try to get DEPhysicians inline expand DEPatientVisits, and want sort entities in DEPatientVisits by VisitDate, you can try:
locolhost/FalconCPDataService.svc/DEPhysicians?$format=json&$expand=DEPatientVisits($orderby=VisitDate desc)
If you are try to sort entities in DEPhysicians according to DEPatientVisits\VisitDate, then, just as the answer from #tanjinfu, DEPatientVisits should not be a collection. Otherwise, which VisitDate of entry in DEPatientVisits you want to used to sort?
In the label we have item.ID + '-'+ item.Description
the value is item which is the object returned from the service.
When a selection is made 001-MyChoice for ex. from the autocomplete, the value which is the datacontract object is bound to the autocomplete field as [Object object]. How can I get 001-MyChoice to be bound for the selection ???
Pls help..
It's difficult to tell when you haven't posted any code to review. What format is your data returned from the service? JSON, XML?
I'm sure you're already looked at this link, but here it is just in case:
http://jqueryui.com/demos/autocomplete/#remote
Post some sample code of your js and some sample data of what your service returns for a better answer.
The autocomplete tags returned from your web service need to contain the tag 'term' and I think "ID", then the default call can help pull them out. Although not a perfect example if you look at the Jasonp example in the jQueryUI docs, that may help.
This is from memory but something like
{"term":"dog", "ID": "123"}, {"term":"cat","ID": "2"}
So you have 001-MyChoice as the label and you want it bound as the value?
Then don't specify the object returned as the value. Label and value are not required by the autocomplete. You can specify both if you want one in the dropdown select (label) and the other (value) used as the value of the select.
If you want the select item and the value to be the same, then put the same item in either the label or the value property.
From the jquery autocomplete docs:
The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.
If you need to use the datacontract object, then just assign it to a variable in the select callback function of the autocomplete and you can use it as that.
I'm trying to access the values in the FormCollection inside of an action. I can get the value field by doing:
var value = formCollection["MyDropDownList"];
But I can't seem to find a way to get the display value. Am I missing something obvious? A cast perhaps?
Getting text from an HTML drop down selection list using JavaScript code
To get the text from each option is slightly trickier. We use the selectedIndex property of the selection list to capture the selected option and then pass this value to the options[].text property.
Here is the code
var w = document.myform.mylist.selectedIndex;
var selected_text = document.myform.mylist.options[w].text;
I don't think there's a way to get the display column from the formcollection. Basically, the formcollection is an easy way to interrogate the Request object (Request.Form, Request.QueryString, etc.) and the only thing that goes into that are values from input fields.
If you really need to get the display text, you would have to get it from whatever collection you bound the list with and access it via the key (your selected value from the formcollection). For example, if it's a dictionary collection that you bound to the list, use that same dictionary to lookup the value based on the key.
I would need to know more information as to how you're binding the dropdown to help you further.
That's the normal behaviour. When a form is posted, only the name-value collection generated from the form fields are sent to the server. And of course the inner text of the option tag doesn't belong to that collection.
you do it ok, dropdown list sended shows value of selected item not displayed text of selected item...if you want(from some reason, because I am asumming you are filling that dropdown on model right? :)) to see send a display text also, maybe you can put it in hidden field with javascript on every change of selection in dropdown...
cheers