Kendo Grid missing text after space when using custom DropdownEditor - kendo-ui

I have a Kendo UI Grid which has a DropDown used to edit the row. I want to add the value of two columns from the DropDown to the grid data-source. My example works almost perfectly except that only the first characters in the DropDown field up to the first space get added, anything after that gets truncated. So the DropDown field "PartNumber" with a value="P 2929" ends up being added as just "P".
I have a JS Bin example here that recreates my problem.

In the template for your part number column in your grid you need quotes for the value attribute of the input element. The html isn't valid anymore if there's a space in the value
value=P 1234
instead of
value="P 1234"
You should quote all of them in all of your column templates but it will work when there aren't any spaces in the data value.
You have:
value= #:data.PartNumber || \'\'#
Change it to:
value="#:data.PartNumber || \'\'#"
I tested this in JS Bin and it works like you wanted after the change.

You can change the strip code in your code below:
value="#:data.PartNumber || \'\'#"
by
value="#:(data.PartNumber != undefined ? data.PartNumber : \'\') #"
I already tested and it works!

Related

How to add the title to a Telerik report?

I have a report, which works fine. And now, I want to add a title to it. I would like the header to be the title of the report.
How shoud I proceed to get the above done?
Set the name of the report like normal in the properties window. Then set the value of the Header's text element to:
= ReportItem.ParentElement.ParentElement.ParentElement.Name
Note that the number of ParentElements depends on how many nested elements the header textbox is in. For me, the correct number was three, as =ReportItem.Name returned something like "TextBox2", =ReportItem.ParentElement.Name, returned"Detail" and = ReportItem.ParentElement.ParentElement.Name returned nothing.
Further reading

Insert plain text just before last closing HTML tag

I am using CKEditor in my web app. Once the user is done using the editor, they will choose some products from a selection list.
After that, they will click a preview button, at which time I need to programmatically insert some plain text immediately before the last closing HTML tag in the editor. For example:
Current Editor HTML:
<p>The products you have chosen are: </p>
After Inserting the plain text:
<p>The products you have chosen are: product 1, product 2, product 3</p>
Thank You
EDIT: Try to use jquery
$( ":last-child" ).children().last().append("product 1 product 2 product 3");
var existingContent = CKEDITOR.instances.containerID.getData();
Gets the contents of whatever container you are using to hold the edit into a string var. Change 'containerID' to be the container's css ID. This will be 'editable' if you used the suggested code.
You can write the modified string back by using innerHTML, eg:
document.getElementById('editable').innerHTML=modifiedContent;
You may be thinking why not get the content by innerHTML - the answer is that innerHTML does not preserve formatting.
HTH
For an example of how this works, take a look at codebase/srcedit.php in Hyperframe 4. http://sf.net/projects/hyperframe.

How to add default value to text field that cannot be changed (Ruby on Rails)

I am trying to create a formatted text field that will have its contents then parsed into a Ruby Date object. I think I have the logic for taking a value from a text field and turning that into a date, but I can't figure out the formatting part.
I want a text field that would already have separators in it by default, that the user could not overwrite. So I would want the text field to look like:
__/__/__
And when they tab into the field, the text they type fills in the spaces instead of overwriting everything in there.
Thanks!
not sure about the ruby but you can use jQuery like so:
http://digitalbush.com/projects/masked-input-plugin/
jQuery(function($){
$("#key").mask("aaaaa-aaaaa-aaaaa-aaaaa-aaaaa");
});
and simply use <noscript> in your page header to make sure anyone's viewing your page has the javascript enabled.

Knockout set initial value of an input field where html is allowed

I have two input fields first name and last name.
Application was running really well.
Suddenly someone came in from Mars and input something like this in those input fields
*(~'##~>?<+!""*%$)!
for both first name and last name. Now don't ask me why he did this cause in Mars this is very common. You can try it on this fiddle
http://jsfiddle.net/farrukhsubhani/3RjRF/
This text then went into my database and now when i retrieve it it came back like this
*(~'##~>?<+!""*%$)
which is ok for me as its html and I can place it back into knockout and it gets populated as html as you can see in fiddle above. However this Mars guy then thought that on Earth this is not a nice name to be with so he tried to edit field.
The above fiddle is kind of that edit page which shows him old value at bottom and two fields at top. He does not know html so he thought we have changed his name in input fields however I need to know
When passing text to knockout to give initial value to an input field is it possible to tell it that consider this text as html so it renders properly in input field
The other way around is to send him to http://www.w3schools.com/tags/ref_entities.asp and tell him about reserved HTML characters. This info has been stored in database (using Entity Framework simple person.fname and person.lname both with attribute AllowHTML) so on my fiddle i have just placed it in two variables and you can see how actual text boxes are different than html below. If i dont bind using Knockout then actual text is shown in these boxes and user can edit <>' signs without any problem.
Anyone with a solution before he leaves our planet. This can change alien life on our planet.
Update
If i go into this field and paste (~'##~>?<+!""*%$)" binding works fine and you can copy this and paste it into fiddle to see that. However its not taking that value from Javascript variable to knockout expects it to be a string and html special characters are not shown properly in input field.
We have done another test without Knockout and this text does get rendered within the field when you try to edit it its fine.
We have updated JSfiddle to work without JQuery and its the same result if you store it in a js variable and give not value to input field
http://jsfiddle.net/farrukhsubhani/3RjRF/3/
If we assign value to input field and just use jQuery to populate fullname then it works
http://jsfiddle.net/farrukhsubhani/3RjRF/4/
This last fiddle is a working example and we want Knockout to do what JQuery is doing.
I think the question then comes to how can this text be stored in javascript variable and placed into input field as html text so special characters appear unescaped. You can try unescape on jsfiddle that did not work for us.
Somewhere along the trip into (or maybe out of) your database, the value is being HTML-escaped. It's not Knockout itself that's doing it. You're going to need to track that location down, but you can't just disable it; you're going to have to replace it with something that sanitizes the result or otherwise you're opening yourself up to cross-site scripting attacks (any <script>s from external sources inserted into the input would have complete access to your data).
Any time you see the html: binding used, warning bells should go off in your head and you should VERY carefully to check to ensure that there's NO possibility of raw, unexamined user input making it into the string that gets displayed.
Ok here is what i did at the end
http://jsfiddle.net/farrukhsubhani/3RjRF/7/
I have done following:
I have added value attribute to input field and placed the input text as it came from server into it. Because I am using TextBoxFor in MVC it did that for me.
Before I apply knockout binding I have picked this value up using $('#kfname') and passed it to the actual binding so it used the value that came from server. Previously it was passed like (#Model.fname,#Model.lname)
I think what this did was allowed jQuery to pick up the value and assign it to binding instead of variable
ko.applyBindings(new ViewModel($("#kfname").val(), $("#klname").val()));
Hopefully this would help someone using knockout.

Avoid Special Characters Search in JqGrid Toolbar

I have successfully build Jq GRid with Asp.Net with all the required features except the one to "Avoid Spl Characters in Tool Bar Search" . I tried to find the ID of the toolbar but with no success. Can any one tell me how can we use Regular Expression like stuff to deny entering of Some Spl Char like "/,:,',\" and few others. I dont want the user to enter those char in tool bar search.
The Toolbar Searching has beforeSearch event handler which can return false to stop searching. One can use this for validation of the data.
If you do want to know how to find the searching field manually you should understand following. The ids of the fields in the searching toolbar will be constructed from the "gs_" prefix and the name of the column. You should also understand, that the toolbar is not a part of the <table> element. jqGrid build some dives over the <table> element. For example if your <table> has id="list", the name of the div which contain the searching toolbar as a child (not a direct child) are #gview_list.
UPDATED: I created an example for you. Try to type and text in the search field for names which is not 5 characters long and you receive an error message and the searching will be stopped.

Resources