Does anyone know how to get the `InsertItem` of detail table of radgrid? - radgrid

Does anyone know how to get the InsertItem of detail table of radgrid?
I can get from master table using the following code.
Radgrid1.MasterTableView.GetInsertItem();
But how can I get it from detailtable?

You need the index of the parent item:
RadGrid1.Items[?].ChildItem.NestedTableViews[0].GetInsertItem();
In a EventHandler you can iterate through the parent objects of the sender until the GridEditFormInsertItem.

Related

Property [participants_count] does not exist but exists and can be dumped

I have 2 tables, evenements and participants, represented by 2 models Evenement and Participant.
Those entities are belongsToMany related, so I have a third table evenement_participant following Laravel's naming conventions, and inside are foreign evenement_id and participant_id columns.
I'm able to retrieve the relationship and I can
dd($evenement->participants)
which gives me a collection of participants.
In my controller, I have this db call:
$evenements = Evenement::withCount(['participants' => function($query) {
$query->where('is_active', 1);
}])
This withCount generates a participants_count attribute for each evenement.
In my blade view, there is a for-each loop on the evenements collection, and somewhere I do this:
$evenement->participants_count
and I face this error:
Property [participants_count] does not exist on this collection
instance.
However, if instead I do the following in the same blade view
#dd($evenement->participants_count)
it dumps me the count.
I dropped all the evenements to keep just one for testing, and I still have the same error.
Sorry, made a typo in a condition inside my blade loop

How to get original object after modifying with dojo.clone?

I have a object which returns from service say, studentInfo (which has id 1).
I have cloned as below:
this.studentsInformation=dojo.clone(studentInfo);
Now I try to update the cloned object - studentInfo
I have updated (say for id 1) and stored in database. If I create a new student info and try to update in a db, it has to go with id 2. But the object has id 1...
And also if I print this.studentsInformation, it is not showing the original object.. it has got modified object only..
So I want the original object after modifying and also I want to store the updated information after cloning as well. How can I achieve this?
why dont you store a reference in the clone to the original object ?
this.studentsInformation=dojo.clone(studentInfo);
this.studentsInformation.myMama=studentInfo;
Lucian

Filtering with CollectionViewSource in MVVM/XAML in Silverlight

I have 4 tables:
Stores => StoreID , AddressID
Contacts => ContactID, StoreID, DesignationID,
Designation => DesignationID
Address => AddressID
In Entity Query I used Include while getting all the details of the stores.
ObjectContext.Stores.Include("Address").Include("Contacts.Designation");
So I got all the stores with all their contacts and other objects like Address. Now I want to filter Store's contacts but our Domain Service Linq does not allow filtering with Include. It include all the data. So I want to use CollectionViewSource for filtering my child data.
In UI, I have One ListBox for Store Information and within that ListBox -> I have one more list box for store's Contacts and I want this Contacts to be filtered with some condition on its Load...
I can't figure out how to do this with MVVM or directly in XAML. But Doing it with MVVM is preferably better.
Can anyone please help me solving this problem?
Thanks for your time and help.
You need to first get hold of the default ICollectionView for your source item.
You can do this like so
var collectionView = CollectionViewSource.GetDefaultView(collectionToFilter);
Next, you create a filter delegate like so
collectionView.Filter = delegate(object item){return some boolean expression;};
Hope this helps

Knowing child collections count without loading them in NHIbernate

I'm using NHibernate with FluentNH. I've a simple class called PostCategory and it contains a collection of Posts. The PostCategory class contains a property called TotalActivePosts. When I load all the PostCategories I want the no. of active posts for each category to be populated in this property. How I can do that? Any help is greatly appreciated.
Vijaya Anand
The way I did it is by using a computed property. see item no. 5- arbitrary SQL.
you could use something like:
Select Count(*) from Posts where PostCategoryId = Id And IsActive = 1
see also this question
You can either do what sJhonny recommends or use the lazy="extra" attribute on the mapping. That way you can just do Posts.Count to get just the count without loading all of the entities.
See this SO question:
NHibernate Lazy="Extra"

SPListItem id from SPField object

I am working on create a custom field type and for implementation issue I need to retrieve the ID of the SPListItem in the SPField class which belong to these field type but I can't retrieve it.
For example:
public class myField:SPFieldText
{
// I need ListItemID in this class
}
Can anyone help me please?
SPFieldText is an SPField, which is the schema definition for a field. Its like saying, given an SQL create table statement, give me the id of row x. Can't be done.
I think the logic you are trying to perform should be done in an event receiver, so say when an item is saved, you take the ID and add it to the text field.
I didn't find a solution but I've tried another solution which is
I can get the ID of the item in the New and Edit forms so I saved the ID and the field value as a one value separated by '/' and in the SPFieldText class I've been able to retrieve the ID value from the value of the field