Notes feature in Line chart MVC wrapper not displaying - kendo-ui

I'm trying to use the Notes feature to add text to plotted points in my Line chart. When I try setting the Format() or Template() expecting the value to be populated by the bound value nothing displays. If I set the Text() field to a some string value, the text is displayed as expected.
series.Line(d => d.Revenue)
.Notes(notes => notes.Label(label => label.Position(ChartNoteLabelPosition.Outside).Format("{0:C0}")).Position(ChartNotePosition.Top))
.Name("Revenue").Color("#00326f")
.Labels(labels => labels.Position(ChartPointLabelsPosition.Above).Format("{0:C0}")).Visible(true);

It should work if you replace the first line of your sample with:
series.Line(d => d.Revenue, null, d => d.Revenue)

Related

Kendo TreeView in grid display 'undefined'

I had this kendo grid demo, and on outletID column, i want to use kendoTreeView with checkbox, so multiple selected outletID possible. But when edit it display undefined result, and the template that display outletName also not working. Appreciate your help
DEMO IN DOJO
Your tree needs dataTextField and dataValueField set.
Your column template doesn't know where to look for the outletName. Kendo supports 1-N relationships, but I'm not aware of N-N.
The data in your template is the current row of the grid. For the first row, that would be {"id":"1","outletID":"LA2,LA3","accountName":"Data1"}. You need to process that data yourself. For instance:
template: "#= (data.outletID) ? data.outletID.split(',')
.map(x => TreeData.find(y => y.outletID == x)['outletName']) : '' #"
For the editor, the value of a dropDownTree is an array. Your row has a string. You need to do two things:
1 . Init the editor's value in the function outletTree:
if (options.model) {
ddt.value((options.model[options.field] || '').split(','))
}
2 . When the dropDownTree's value changes, update your grid row:
change: e => {
const value = e.sender.value();
console.log(value)
options.model.set(options.field, value.join(','))
}
Here's an updated dojo: https://dojo.telerik.com/#GaloisGirl/oYEGerAK . The "Update" button doesn't work yet, probably because the dataSource must support edition. Here is how to do it on local data.

How do I Dynamically show the pageSize in yii2?

For now I have set static pagesize in my search function, but now I need to create dropdown for user to change the pagesize from front end. For e.g like 10,20,50,100.
I got the code but it is for yii previous version.
If I had to do it I will use the following approach.
Create a Dropdown for the page sizes, you can adjust the dropdown inside the layout option of the gridview if you want it between summary text and items list or add it before the gridview. like this image, you can wrap it with div to adjust the CSS for it yourself.
The main thing to do is to include the id of the drop-down to the filterSelector option so that every time the gridview is filtered the dropdown value is also submitted and also whenever you change the dropdown.
Your GridView will look like below
GridView::widget([
'dataProvider' => $dataProvider,
'layout'=>'{summary}'.Html::activeDropDownList($searchModel, 'myPageSize', [1 => 10, 2 => 20, 50 => 50, 100 => 100],['id'=>'myPageSize'])."{items}<br/>{pager}",
'filterModel' => $searchModel,
'filterSelector' => '#myPageSize',
'columns'=>[
// your column configurations.......
]
]);
Declare a public property in the searchModel
public $myPageSize
Add that property to the safe rules inside your searchModel
[['myPageSize'],'safe']
And then update you search() method inside the relative SearchModel you are using with the GridView. You should assign the pageSize option of the query inside the $dataProvider with the new property defined but make sure you add this line after the $this->load($params) statement.
See below
$dataProvider->pagination->pageSize = ($this->myPageSize !== NULL) ? $this->myPageSize : 10;`
Here we are setting the default page size equal to the minimum option inside the drop-down we created, otherwise it would be updated when ever you change the dropdown.
Now try changing the dropdown you will see it working. Hope this helps
Thank you Muhammad!
Your answer helped me, but on the layout I had to modify the array for the select:
Where you have "1 => 10, 2 => 20," I had to change it to "10 => 10, 20 => 20,". Otherwise it pagination goes one by one or two by two.
It ended up like this:
'layout'=>'{summary}'.Html::activeDropDownList($searchModel, 'myPageSize', [10 => 10, 20 => 20, 50 => 50, 100 => 100],['id'=>'myPageSize'])."{items}<br/>{pager}",
The rest worked perfect!

UpdateOrCreate not working has expected

im trying to user the method "updateOrCreate", and works almost has expected but with a problem.
For example if the record doesnt exists it creates, untill now great, but for example if i change a value in my case the "mybankroll" value it creates another record. I can that understand that is creating because one of the columns record value doesnt exist, but i dont understand how the update actions is fired.
My code example:
UserBankroll::updateOrCreate(
['my_bankroll' => $request->mybankroll, 'currency' => 'EUR'],
['user_id' => Auth::user()->id]
);
But if i try to update the value of my_bankroll, instead of updating it created another record.
You seem to have your arrays backwards.
The first array should be what you are matching against, the second array should be the update values.
https://laravel.com/api/5.0/Illuminate/Database/Eloquent/Model.html#method_updateOrCreate
UserBankroll::updateOrCreate(
['user_id' => Auth::user()->id],
['my_bankroll' => $request->mybankroll, 'currency' => 'EUR']
);

How to disable few columns of a row based on a condition in Webix datatable

I have a webix datatable with column names as 'No.', 'Name', 'Action', 'Phone', 'Comments'. Below are the types of the columns :
'No.' and 'Name' columns are always readonly.
Rest three 'Action', 'Phone' and 'Comments' are editable plus cells under 'Action' and 'Phone' columns are having dropdown menus.
Requirement:
Lets say, for a particular value in 'Name' field (for example 'Mark') , I want to disable all the editable fields of that particular row. Either the row should rendered as disabled(readonly) or just before editing the editable fields would turn disabled(readonly). All other rows should have their usual behavior.
I have tried to achieve this with onBeforeEditStart event here at https://webix.com/snippet/3bafd99c
However I am facing issues to implement it. Any help would be great.
Thanks.
You can use code like next
onBeforeEditStart:function(id){
return this.getItem(id).id1 !== "Mark";
}
https://webix.com/snippet/306471fc
The getItem call returns the current row, and next check compares the value of name column with a control one. ( using id:"name" in columns's config will make the above line much more readable )

kendo dropdown bindto enum - text string data int

I am using following Code for my model m:
#(Html.Kendo().DropDownListFor(m => m.*Property*)
.BindTo(Enum.GetValues(typeof(*Enum1*))))
This works fine but of course is not very user friendly. I want to display string values but send int values.
Using .BindTo(Enum.GetNames(typeof (Enum1)).ToList())
does not help as I need to send the actual int values.
Using .BindTo(new List{...}
I also need to call .toString() on my value which needs to be int.
What am I supposed to do?
Convert the enum into a Dictionary and bind the result to the dropdown.
.DataTextField("Value")
.DataValueField("Key")
.BindTo(Enum.GetValues(typeof(*Enum1*)).Cast<*Enum1*>().ToDictionary(e => (int)e, e => e.ToString() );
Hope this helps. Good luck.

Resources