To Bind RadGrid Dynamically - radgridview

I using Telerik tool. I need to change my itemsource and selected item of the RadGrid dynamically
Can any one guide me how to Bind selected item and Itemsource of the Grid in CodeBehind.
I posted Support in Telerik ,but they didn't reply me properly. Its urgent, Please guide me..
Thank You

Set the ItemsSource an ICollectionView. I define a property like this in my view model:
public ICollectionView ProductsCollectionView { get; set; }
After the service call I set it like this:
_internalSpecificationCollection = new ObservableCollection(e.Results);
ProductsCollectionView= new PagedCollectionView(_internalCollection);
You can also then add a Telerik data pager and also bind this to the ICollectionView.
You then have access to the event ICollectionView.CurrentChanged in which you can get the ICollectionView.CurrentItem

Related

Xamarin form - How to customize picket control

I am using latest xamarin build 4.5 and trying to apply picker control with following facilities..
Binding option- I could not see ItemsSource property in latest xamarin release. I have used following code to bind picker control in c#
_pcPicker = this.FindByName("pcPicker");
foreach (var item in ParentCategory)
{
_pcPicker.Items.Add(item.Name);
}
I need to bind category id also along with category name...please guide me how to bind and get id of selected category.
I could not follow this link for bindable picker - https://blog.xamarin.com/new-bindable-picker-control-for-xamarin-forms/ ... example given is not complete.
I need add to additional link (Add New category..) at the end of the picker list just as shown in below image.
Please guide me how to customize picker control to achieve these two requirement-
Thanks,
#Paul
This nuget package is great and will allow you to achieve what you want.
https://github.com/rotorgames/Rg.Plugins.Popup
It allows you to create a pop up of any type of page. So for your picker, you could create a view that has a StackPanel, that has a ListView (so you can bind your ItemSource) and then 2 buttons New Category, Edit Category.

Display 'No records' in Wp7 Listbox when ItemSource does not have data

How can I show "No records found" when there are no data in itemsource bound to a Listbox.
If I add a new textbox it gives an exception as cannot add data to readonly collection.
Thanks and Regards,
Kanaya
You can have a Grid with a TextBox and the ListBox in front, if the ListBox has content it will hide the TextBox and/or Bind the Visbility to the Count property of your ObervableCollection with a converter.
instead of doing this. check the count and hide the listbox if there are zero records and show a textblock with the message.
how are you binding data to the source of the listbox?
If its by databinding with a property in its viewmodel, then simply check that property for null or empty . This will serve the purpose.
Providing more info or code you are using can bring in more help.

How to get MVC web grid dropdown column value using javascript or from controller

We have a dropdown list column in ASP.NET MVC 3.0 WebGrid. User will select a item from that list for each row.
When i click on submit I need to capture the selected value for each row.
Can anyone please give me a sample code for doing this from controller.
Thanks in advance
You can make a column with DropDownList control using a html helper:
grid.Column("List", header: "List", format: #<text>#Html.DropDownList("selection", someItems)</text>)
Then put the whole grid in a "form" statement, which refers to "Save" action in your controller, and create that "Save" action method like this:
public ActionResult Save(string[] selection) {
[...]
}
Why don'y you give telerik.mvc grid a try. It's super smooth and handles such scenarios pretty well. Moreover the effort is pretty less in setting it up.
You can download it as a nuget package.
Examples are here http://demos.telerik.com/aspnet-mvc/grid

Displaying radio buttons using ASP.NET MVC EditorForModel

I am using EditorForModel bound to a ViewModel. I have to display a list of radio buttons on my form, but I'm not sure how to do this using Data Annotations. Is this possible? Or can I not use EditorForModel in this case?
My ViewModel can be flexible, as it's only a DTO and I am manually mapping it to my data access layer.
Create a custom editor template:
[UIHint("RenderAsRadioButtonsList")]
public SomeObject ToBeRenderedAsRadioButtons { get; set; }
and then, in Views/Shared/EditorTemplates, create the partial view:
Views
/Shared
/EditorTemplates
RenderAsRadioButtonsList.cshtml
See this Geekswithblogs post on a radio button helper.
Also another one.
A google search will turn up additional resources for radio button lists in ASP.NET MVC.
Here is some code over at GitHub, too.

Setting Telerik MVC grid column properties during an Edit

I have an MVC 3 Razor Telerik grid. I have an Edit comand on the row.
When a user clicks on Edit (this places the grid in Edit mode with an Update and Cancel button), I want to set a property for two of the columns to readonly.
When the user clicks on Cancel or Update, I want to set the columns back to full permission.
I know there must be some properties in the controller I should be able to set when the Edit button is pressed for this, but have not seen any docs on how to accomplish this.
How can I do this?
I'm using version 2011.2.712.340 of the controls.
What your describing above sounds a little bit confusing. The purpose of the readonly property is to ensure that when your row enters edit mode the columns that had readonly explicitly set cannot be edited, which seems to be what you're looking for. When in regular read mode all columns will have the same permission whether or not readonly was set, since you are just viewing the data and not editing.
Edit after clarification from comment:
Seems like you want to have this field editable when you are inserting a record, but not when you edit the row. Well, this can be done using some JavaScript. If you use Ajax binding (the only way to fire this event) you can do the following by subscribing to the onEdit client-side event:
...
.ClientEvents(clientEvents => clientEvents.OnEdit("onEdit"))
...
And here's the JavaScript:
<script type="text/javascript">
function onEdit(e) {
var form = e.form;
var mode = e.mode;
if (mode == "edit") {
var country = form.Country; //Country is a public property of my Model
country.disabled = true;
}
}
As you can see above, I get the form with the associated edited row and specifically grab the field associated with the property I do not want to be edited and disable that input element.

Resources