Add a "lookup" column in a Kendo Grid - templates

I have a Kendo Grid which represents a many-to-many join table (between Parts and Templates). I want to look up the PartID with a combo box that lists parts by PartNumber instead of by PartID.
A rough image of what I want to acheive.

The question is not clarified. Basically how to deal with foreign key columns is covered in this demo. Also this one is pretty similar.

Related

Select one record from related table if exists, else return None

I have this two models:
class Box(models.Model):
class BoxImages(models.Model):
box=models.ForeignKey(Box)
img=models.ImageField()
cover=models.IntegerField(default=0)
Only one image can be a cover image for a box and a box might not have any images at all. What I want now is to get list of boxes along with their cover image. But django uses inner join and brings boxes that have corresponding cover images only.
Box.objects.filter(box_boximages__cover=1).values('id','box_label')
How do I force it to go with left join or left outer join since i read the ORM decides on its own which join to use?
If you want to have all boxes, no matter whether they have a cover image or not, just drop the filter. The filter effectively reduces your queryset to only those Boxes that have a cover image.
Box.objects.select_related('box_boximages').values('id','box_label', 'box_boximages__cover')
select_related will fetch the related BoxImages in the same query (if they exist). The queryset will contain all Box objects, even if they don't have BoxImages.
EDIT:
It returns all images; the box appears 5 items cos there are 5 pictures for it.
Yes, you are correct. values will add entries per fkey relation. There are several ways to cope with that.
(a) simplest is, not to use values but simply iterate over the queryset and use the Box instances with their related BoxImages. The code will be easy to understand. With the select_related you should also be fine performance wise.
(b) use aggregation to only fetch the box images that are covers. Have a look at the aggregate function. You can use it in combination with Exists to find the cover images (or Max).
(c) Create two QuerySets, one with Boxes without BoxImages and the other using the BoxImage Covers to get all the related Box instances. Combine those two.
Personally, I think (a) is the simplest and therefore best to understand when reading the code at a later point or for other developers.
If you always end up selecting based on cover versus not-a-cover image and you have the freedom to change the models then you could think about using two models + model inheritance and create BoxCover (OneToOneRelation to Box) and BoxImage (n:1 to Box) models. This would be the easiest to understand and handle.

QSqlTableModel working with filter

I have a QSqlTableModel that has 3 columns that I want to filter. Sometimes I want to filter on one of the columns, sometimes on all 3 columns and then only on two.
I cannot show any code as i have not written any. I am thinking on using a string, which is plug on the model->setFilter() function, that depending on the button pressed adds or take out parts of this string to form the filter phrase. Is there something that I missed on the description of the QSqlTableModel that would do this more efficiently?

Infragistics UltraGrid - How to use displayed values in group by headers when using an IEditorDataFilter?

I have a situation where I'm using the IEditorDataFilter interface within a custom UltraGrid editor control to automatically map values from a bound data source when they're displayed in the grid cells. In this case it's converting guid-based key values into user-friendly values, and it works well by displaying what I need in the cell, but retaining the GUID values as the 'value' behind the scenes.
My issue is what happens when I enable the built-in group by functionality and the user groups by a column using my editor. In that case the group by headers default to using the cell's value, which is the guid in my case, so I end up with headers like this:
Column A: 7F720CE8-123A-4A5D-95A7-6DC6EFFE5009 (10 items)
What I really want is the cell's display value to be used instead so it's something like this:
Column A: Item 1 (10 items)
What I've tried so far
Infragistics provides a couple mechanisms for modifying what's shown in group by rows:
GroupByRowDescriptionMask property of the grid (http://bit.ly/1g72t1b)
Manually set the row description via the InitializeGroupByRow event (http://bit.ly/1ix1CbK)
Option 1 doesn't appear to give me what I need because the cell's display value is not exposed in the set of tokens they provide. Option 2 looks promising but it's not clear to me how to get at the cell's display value. The event argument only appears to contain the cell's backing value, which in my case is the GUID.
Is there a proper approach for using the group by functionality when you're also using an IEditorDataFilter implementation to convert values?
This may be frowned upon, but I asked my question on the Infragistic forums as well, and a complete answer is available there (along with an example solution demonstrating the problem):
http://www.infragistics.com/community/forums/p/88541/439210.aspx
In short, I was applying my custom editors at the cell level, which made them unavailable when the rows were grouped together. A better approach would be to apply the editor at the column level, which would make the editor available at the time of grouping, and would provide the expected behavior.

Qt, creating very custom table

Hello! I wonder if there is a way of making such kind of table with combined cells using Qt.
Any advices?
You can use QGridLayout, add QFrames and set the rowSpan and columnSpan of each item to group cells.
You will have to come up with your own controller, though, for applying data to the cells.
As RobbieE said in comments QTableView::setSpan() function does this job very well!

Looking for a spreadsheet (or table) view for django

Pardon the dumb question, but where can I find a view for Django to display "tables" in a spreadsheet-like format (i.e. one record per row, one field per column).
(The fact that I have not been able to find one after some searching tells me that maybe my noob-level understanding of Django views is way off-base.)
Here I'm intending the term "table" fairly generically; basically, think of a table as an "list of lists", with the additional constraint that all the internal lists have the same length.
(It would be great if this table had spreadsheet features, such as the possibility of sorting the rows by clicking on the column headers, or of cutting and pasting arbitrary rectangular subsets of the cells, but I realize that this may be hoping for too much.)
An other way to do it is to use tabular inlines but a list view is what you are looking for.