KENDO UI : Invalid Template Format - kendo-ui

I am very new to Kendo ui, and I am trying to create a template but I am getting the "Invalid template" error. What I want to achieve is to check if the field name is valid (exists on the current object) so I can avoid the undefined property error.
template: "<div><input type='checkbox' value='#=" + field + "?#= "+ field +":\"\"#'/>#=" + field + "?#="+ field +":\"\"#</div>"
I am trying to reproduce the reproduce this example http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/checkbox-filter-menu , but some objects of data I have, does not contain some properties.

You could use if/else instead of the ?: operator.
So adapting on that Kendo Example you mentioned, the below snippet uses the value of "field" if it exists otherwise places the alternative "\", which is what I think you were trying to achieve above
template: "<div><input type='checkbox' #if("+field+"){# value='#:" + field + "#'/>#:" + field + "#</div>#}else{#value='\'/> \</div>#}#"
Alternatively the following template won't create an element at all if "field" doesn't exist:
template: "#if("+field+"){# <div><input type='checkbox' value='#:" + field + "#'/>#:" + field + "#</div> #}#"
For reference see the Template Syntax section here:
http://docs.telerik.com/kendo-ui/framework/templates/overview

Related

ASP.Classic Getting value from input to POST parameter

Please excuse me if this question is dumb.
I need to get an input value and pass it in a POST parameter like follow:
SQL = "[proc_Happy]" & Request.Cookies("UserID")& "," & Request.Form("MYINPUTFIELD")
I have tried hardcoding MYINPUTFIELD with (it worked!):
SQL = "[proc_Happy]" & Request.Cookies("UserID")& "," & 54555152
My input in the asp page looks as follow:
<input type="number" name="MYINPUTFIELD " id="MYINPUTFIELD" value="<%=MYINPUTFIELD%>">
Things I have tried:
Getting the value with JS - failed.
Notes:
MYINPUTFIELD is an int
Is your input field in a form, i.e. is it between <form...> and </form> tags? If no, that's your problem right there. If yes, what does the <form...> tag have in it? Does it say method='get'? If yes, then your inputs are being put in the querystring, not the form object. For Request.Form(...) to work, your form needs to say method='post'.
If you need this code to work with both form methods, you can do something like
dim MyInputField
MyInputField = Request.Querystring("MyInputField")
If MyInputField = "" Then MyInputField = Request.Form("MyInputField")
'make the "OMGSQLINJECTION!!1!" people just go away already
'(note to such people: he's using a frigging stored procedure.)
If Not Isnumeric(MyInputField) Then
MyInputField = 0
End If
SQL = "[proc_Happy]" & Request.Cookies("UserID")& "," & MyInputField

API Blueprint: Semantic Issue "no value(s) specified"

In my blueprint I'm defining a data structure and try to use it like so
+ Attributes
+ error: (Error Details, required)
Data structure definition at the end of the document:
# Data Structures
## Error Details
+ code : 1234 (number, required) - see list of error codes
+ message: User not found (string, required) - a human-readable error message
The resulting sample response body looks just like expected but the validation on apiary.io shows semantic issues for each of the places where I use constructs like this, saying "No value(s) specified".
Am I doing something wrong or is it a problem with the apiary.io parser?
I had the same problem and solved it by
omitting the colon
separating the object definition and type (see owner in this example):
Company (object)
name: Company name (string)
owner (OwnerResponse) (object)
A similar answer to other current answers, but none the less this fixed it for me.
No good:
+ Attributes
+ `status`: OK
+ `data`:
+ 5 (Channeldata)
+ 7 (Channeldata)
Fix:
+ Attributes
+ `status`: OK
+ `data`
+ 5 (Channeldata)
+ 7 (Channeldata)
As others have noted, losing a colon in the right place can fix things.
Attribute section can be also defined as + Attributes <Type Definition> (specification), so defining + Attributes (Error Details, required) should fix the given semantic issue.
Edit:
You have to omit a colon between attribute's name and its type, when an example value is not defined:
+ Attributes
+ error (Error Details, required)
Missed that before, sorry.

Get Item Text with Persits Asp.Upload

I need help with the component Persits's AspUpload. I need a simply method to get item text from form. I read the manual online http://www.aspupload.com/manual_simple.html but i think that the method presented is not good. In the manual the used method is:
<%
For Each Item in Upload.Form
Response.Write Item.Name & "= " & Item.Value & "<BR>"
Next
%>
I need to get the item.value from item. I already know the item.name. I try with this code, but it doesnt run
var1 = Upload.Form.Item.Name("var1").Item.Value
The error is:
Wrong number of arguments or invalid property assignment: 'Upload.Form.Item'
I've found a solution but i don't like it
For Each Item in Upload.Form
if Item.Name = "var1" then var1=Item.Value end if
Next
Do you have any more elegant solution? Thanks
Admittedly the documentation isn't the clearest but Upload.Form is a collection the documentation says;
To reference an individual form item of the collection you may use a 1-based integer index, or a string corresponding to the NAME attribute of a text item of your upload form.
So you can access it like most collections in Classic ASP
name = Upload.Form("var1").Name
value = Upload.Form("var1").Value
As long as var1 equates to the NAME attribute of the HTML form field element (INPUT, SELECT, TEXTAREA etc).

Add string of text to DropDownList in ASP.NET MVC

In an ASP.NET MVC 3 Web site I have a view with the following code (Razor):
#Html.DropDownList("SessionYear", new SelectList(ViewBag.SessionYears as System.Collections.IEnumerable, "", "", Model.SessionYear), String.Empty)
ViewBag.SessionYears is an IEnumerable<int>.
The output is something like this:
<select id="SessionYear" name="SessionYear"><option value=""></option>
<option>2013</option>
<option selected="selected">2012</option>
<option>2011</option>
<option>2010</option>
</select>
That's great, however, what I'd like to do now is add a bit of text to the text displayed in the drop down list, so each option looks a little like this:
<option>2013-2014</option>
<option selected="selected">2012-2013</option>
I've tried playing around with the different options, but none are working, and I've exhausted the overloads.
Can I do this with the DropDownList helper, or do I need to implement this in a different way?
EDIT: And while I could probably convert SessionYears to an object that has an int and string to resolve this, I'd prefer not to. But if that's what I've got to do, that's what I'll do.
EDIT 2:
The code I'd expect to work is:
#Html.DropDownList("SessionYear", new SelectList(ViewBag.SessionYears as System.Collections.IEnumerable, "", (Model.SessionYear + "-" + (Model.SessionYear + 1)), Model.SessionYear), String.Empty)
However, I get the following error:
DataBinding: 'System.Int32' does not contain a property with the name '2012-2013'.
Which I suppose makes sense, since Model.SessionYear is an int. This is also why I'm thinking I have to create a new object that contains SessionYear as an int and then some other property that contains (SessionYear + "-" + (SessionYear + 1)) (as I've done in the past with other models).
But I would expect for there to be an easier way.
I am not sure if I'm understanding the question right but why aren't you setting the dataValueField and dataTextField?
Maybe build your SelectList something like this:
#Html.DropDownList("SessionYear", new SelectList(ViewBag.SessionYears as System.Collections.IEnumerable, Model.SessionYear, Convert.ToChar(Model.SessionYear) + Convert.ToChar(Model.SessionYear + 1), Model.SessionYear), String.Empty)

how to create a hyper-link in iReport?

I'm using iReport-3.7.6
I have created a sample_Report1 with one parameter as (Project_name) and
I have created the Sample_Report2 with one parameter as (Employee_No)
Now I want to create a hyper-link in Sample_Report1 to Sample_Report2.
(pass the employee_no as a parameter to Sample_Report2 from Sample_Report1 using hyper-link)
rclick on the text field > link parameter
hyperlink target: Self
hyperlink type: ReportExecution
A. add "link parameter name" = uri (well in my repository setup this is what I use)
then Value Expression is the URL enclosed in " "
B. Click on add again "parameter name" value will be the field parameter
when you click mouse over on the link it should be like this
www.yoursite.com/reports/executeReports.jsp?uri=/path/report/yearend&year=2010
this is your URI = "uri=/path/report/yearend"
this is your parameter = "year=2010"
hope this helps...

Resources