we can ref a grid panel by:
ref: 'grid', selector: 'contactlist gridpanel'
but how to ref the CheckboxModel in the grid panel?
Any help is much appreciated!
First you should understand the concept of refs & id. refs is an array used to hold references to some ExtJS components which have id. According to documentation refs is:
One of the most useful parts of Controllers is the new ref system.
These use Ext.ComponentQuery to make it really easy to get references
to Views on your page.
What is id? Quoting from ExtJS documentation:
The unique id of this component instance.
id property is present for all classes that are extended from Ext.AbstractComponent. Other ExtJS class do not have this property. The value is either auto generated or assigned by the user when creating an instance of the component. It is used as a selector when you don't have object reference of the component. Also, remember that the component's HTML element will have it's id property set with the same value (either auto generated or user defined). This is done, so that you can provide custom CSS and styling of your own.
Now, coming back to refs.. it is an key/value pair array that hold a variable and selector of the component. It is not intended to hold all the references of objects in your view! In the above code, you already have a reference to the view. To get the selection model of your grid, you have to use the methods available with grid panel:
this.getGrid().getSelectionModel()
Related
(I'm using Prism Dryloc) My application consists of two views. The first contains a single list view displaying strings and the second - an entry and a button.
The listview is bound to an observable collection in the first page's View Model. How can I add to the observable collection from a different view?
Great question! You're essentially trying to pass data between views, and there's several ways of passing data between Views in Xamarin.Forms.
The two ways that seem relevant for your case:
Either making the ObservableCollection a public static object (so there's only one global instance of it). Not recommended.
The better way is to use the messaging center so that the second page publishes an event when the button is pressed, that the first page is subscribed to. And it passes that information that gets added to the list.
If these don't work, elaborate your use case and I'll suggest some more
I want to store id in back of the page. in web application we are using Hiddenfield for this. but i am not getting any way in xamarin forms. how do i hold unique id on page?
Is there any way to to hide any label or any text field so that i can store ID in it.
I'm not sure what do you want to here, but why don't you just add a Label and set its IsVisible property to false? It'll act like a HiddenField.
Or you can just set the value Tag property of any of your other fields with the Unique ID.
Another way is why not use MVVM Pattern? In order for you to easily work with data, which I would recommend but will take you alot of time to set up.
But I guess what you're looking for is a quick fix, The first two would suffice.
Hope it helps!
As #mindofai says, if you use MVVM then your Id can just be a field or property of the PageModel associated with the Forms page. You don't need hidden UI elements.
If you don't find Tag property for some reasons, you can still use ClassId for bindable field or StyleId for plain text.
I've been trying to make sense the following article explaining how to use Realm in Xamarin:
https://blog.xamarin.com/cross-platform-development-with-xamarin-forms-and-realm/.
Realm seems to integrate nicely with the xaml UI for simple objects, but how does this translate to more complex objects that have children?
When showing the add/edit page for an object, I need to show a list with all the object's children. I want to be able to show the add/edit page for those children when tapped in the list. The problem is that there is already a transaction open in the first add/edit page and I can't open a second one.
The only option I see so far is to not use transactions and to bind fields to separate member variables then copy those values in a Realm object and save it. But then I don't see the real advantage in using Realm.
Thank you!
I have a Model object with a List collection of sub objects. I need to load the form fields for the sub object to the page, and provide a link to dynamically add form fields for a second object. So in other words, multiple sub objects can be created via one form and one post back.
My first thought was just to put the form fields in a partial view and load the view via Ajax.ActionLink. This worked but the problem comes in when trying to uniquely identify each object in the collection and bind the collection of objects on postback. For this it seems the correct usage would be to use an #Html.EditorFor() helper, but I don't know how to call that via Ajax to dynamically add the object's editor template to the page when the link is clicked.
It sounds like you were on the right track with regards to a partial view, you'll just need to sort out the name property of your inputs so you can correctly bind to a collection of objects.
Have a look at this article by Phil Haack explaining how binding to lists works, or google for something more up to date with razor syntax.
I created a custom control that is binded to a a Domino Document data source. I embedded it in a page so that I can display it in a Dojo dialog. It has 2 properties: dialogId and docId. The document data source's Document ID property is set to compositeData.docId. In the page, I set the docId property to a viewScope variable, that will be set when an entry in a view is clicked. What I want to accomplish is that the dialog will display the document that the current view entry (that was clicked) represents. But it seems that the compositeData.docId is not set on partial or even full refresh. Is there a way to do this that the custom control will be binded to the document? I need to have this binding so that I can easily do a server-side validation when I submit the dialog. Or if there is another way, can you also put it here? Thanks a lot!
set the datasource as the document, and then edit mode, then you have a place to compute the doc id, i usually compute the doc id to a viewScope, that i set when i click the item in the repeat control
More details here.
I would prefer the DocId to be transfered via the custom control parameters rather than a Scope variable. Using the Scope breaks the custom control design principle of being self contained. You can use the yourCC.PropertyMap to actually update a value, so the hand over of the parameter will work - of course your control then needs to be refreshed so the data source is recomputed. Hope that helps.