How to set decimal format in Kendo UI MVC NumericTextbox - kendo-asp.net-mvc

I need to display decimal(10,2) value on kendo numerictextbox. I tried following code but is not working:
#(Html.Kendo().NumericTextBox()
.Name("XYZ")
.Decimals(2)
.Step(0)
.Spinners(false)
.Format("########.##")
.HtmlAttributes(new { #maxlength = "11" }))
Also I tried Format("n2"), Format("c2") but nothing is working.

Related

flutter : How To build a grid view with expanded text child

I need to Build this UI Using Flutter, List or (Grid view) of categories which every category has title as text and this texts is different lengths(maybe 4 letters and maybe 15 ).
any suggestions??
Note : data will fetched from API endpoint
You can use Wrap instead of GridView.
Wrap(
children: result
.map(
(e) => Chip(label: Text(e)),
)
.toList()),
More about Wrap and Chip.

Sitecore 8 MVC : How to make the field editable in Page Editor

I'm trying to make my Sitecore site compatible with page editor i.e. all the fields text, rich text editor, etc, should be able to be updated in Page Editor.
So far I've modified the TDS T4 template which returns a HTMLString for each field like below:
public HtmlString HeroImageField(bool isEditable = true, string parameters = "")
{
string renderParameter = GenerateRenderParameter(isEditable, parameters);
return new HtmlString(Sitecore.Web.UI.WebControls.FieldRenderer.Render(
Sitecore.Context.Database.GetItem(this.EntityId.ToString()), "Hero Image", renderParameter ));
}
So, in view I just call Model.HeroImage()
Is there a better way to achieve above? Maybe Glass Mapper comes with out of box support for this (which I don't know).
Sitecore comes with MVC helpers that you can use to make fields editable:
#Html.Sitecore().Field("My Field Name") //Context item by default
#Html.Sitecore().Field("My Field Name", Model.PageItem) //Explicit page item
#Html.Sitecore().Field("My Field Name", Model.Item) //Datasource item (may be context item)
My recommendation is also to use a controller to load a different view for editing. There is often a different visual needed for authoring fields. Carousels/tabs should be flattened out, validation messages need to be exposed, etc.
See more at:
http://sitecore-community.github.io/docs/sitecore-mvc/rendering-content/
Glass mapper has something OOTB for that. You can use the extended WebViewPage GlassView and use the Editable methods as described here:
http://glass.lu/Mapper/Sc/Tutorials/Tutorial14

Sitecore Speak UI : How to manipulate column value of List Control before displaying in list .

I am working in speak UI . I have list of items to display in list . But before that i have to check one column value and need to manipulate this value with a Icon to display . How can I implement this change in SpeakUI . Please help
Simple option:
If the data you receive is directly relateable to the icon you want to display:
Set your DataSource on your ListControl to a ListControl Parameters item with your ColumnField items underneath (as outlined in Sitecore doco or other blogs). In the HTMLTemplate field for your column, you can use the value as the source of an image or CSS class with background image style.
<img src="{{YourField}}" />
or
<span class="{{YourField}}"></span>
where your span class styles your icon.
More complex but customisable:
I'm not sure which datasource you are using, but I am a fan of the JsonDataSource by Anders Laub as it's very simple to use and customise (you only need to add 2 small files).
To your SPEAK renderings you add your JsonDataSource, and ListControl with Items property: {Binding JsonDataSource.Json} (and DataSource as required)
Then in the javascript for your page (defined in your PageCode rendering) you can add items to this datasource and customise as required:
jQuery.ajax({
type: "GET",
dataType: "json",
url: "/yourApiCall" + params,
cache: false,
success: function (data) {
var total = 0;
for (var i = 0; i < data.YourItems.length; i++) {
app.JsonDataSource.add({
Col1: data.YourItems[i][0],
Col2: data.YourItems[i][1],
Col3: data.YourItems[i][2]
});
}
},
Where Col1, Col2, and Col3 are the names of your columns, and YourItems is the array of items you are receiving from your ajax call.

Sitecore SPEAK UI set selected row of ListControl

I have a SPEAK UI dialog with a ListControl bound to a custom JSON datasource. This works and the ListControl is correctly populated. My JSON data looks something like this:
[
{
"itemId":"{BA26159A-194D-4A3C-9D1A-DA9472F11BE0}",
"selected":true
},
{
"itemId":"{E651D0CD-0E7E-4903-8E26-0D1D5A168E69}",
"selected":false
},
{
"itemId":"{E651D0CD-0E7E-4903-8E26-0D1D5A168E70}",
"selected":false
}
]
Is there a way to ensure the relevant row of the ListControl is selected ("selected":true) when the dialog loads?
You can set the ListControl's selected item ID like this: this.MediaResultsListControl.viewModel.set({selectedItemId:"ITEMID"})
(Sitecore.Speak.app instead of this during dubuging in the console)
If you call this.MediaResultsListControl.viewModel.selectedItemId() you can see the selected item has been set by the above method.
Wondering on page load, if you can set the ListControls selected item id, from the page code manually using this method?
Looking at the JS for the list control. It calls this on click of a row. Wonder if you can replace this to trigger selected row?
selectRow: function (row, rowModel) {
this.$el.find(".active").removeClass("active");
row.addClass("active");
this.model.set("selectedItem", rowModel);
this.model.set("selectedItemId", rowModel.get("itemId"));
},

Get/Set igGrid combo cell value

I have an iggrid that is using a JSON data source for the main grid data and the combo box in one of my fields.
I have created the grid and the combo and the data is there. When I change the combo value and commit the grid the main grid column value does not change. I can see this by assigning a default value to the column and then changing it via a combo box.
I am working off of this example.
http://www.infragistics.com/products/jquery/sample/combo-box/grid-editor
Combo Data
occCodeData = [
{ "ID": "0", "OccCode": "Food" },
{ "ID": "1", "OccCode": "Beverages" },
{ "ID": "2", "OccCode": "Electronics" },
{ "ID": "3", "OccCode": "Cookies" }
];
My grid data is stored in a JSON variable in javascript pulled from a web api. I have verified the data is valid using a console write.
Does anyone have this working with standard JSON, JS, and HTML? This main issue is when I change the combo value it does not update my JSON data behind the scenes. The GUI grid changes fine.
When you have editing in the grid, by default the autoCommit option is set to false (meaning the UI updates but the values are not committed to the data source). You can change this to true in order to automatically commit to the data:
//Initialize
$(".selector").igGrid({
autoCommit : true
});
//Get
var commit = $(".selector").igGrid("option", "autoCommit");
Or you can call the commit method manually:
$(".selector").igGrid("commit");
I figured it out. My Sample occCodeData data did not match my current value.
So my default value pulled from the database was 129 but my possible values were 0,1,2,3. This was causing the combo not to change the value because it did not have a match in it's own listing.