inlines

Highlight Search TextBlock

心已入冬 提交于 2020-03-18 15:38:57
问题 My goal is to create a custom TextBlock control that has a new dependency property, SearchText. This property will contain a regular expression. All occurrences of this regular expression in the text of the TextBlock will be highlighted using a custom style (another DP). My current implementation involves clearing all of the Inline objects in the TextBlock's InlineCollection. I then fill the TextBlock with runs for unhighlighted text and runs for highlighted text with the style applied (this

Read C# Textblock Text Property filled using Inlines

只愿长相守 提交于 2019-12-31 03:04:29
问题 Let us say that I have an empty Textblock : textblock1.Text = ""; Then I only put Inlines content in it with these two statements: textblock1.Inlines.Add(new Run() { Text = "A. ", Foreground = Brushes.Red }); textblock1.Inlines.Add(new Run() { Text = responses.Current.Value, Foreground = Brushes.Black}); The amazing stuff is that I can visualize the content properly in my window, however the Text property of the Textblock keeps being empty! This causes a problem because I need to pass the

Django admin - how to save inlines?

心已入冬 提交于 2019-12-30 06:48:32
问题 I need to override save method of inlines in admin. While saving photos, I need to add user id to DB column. I cant make it in model because there is no request data there. How can I do it in admin, to somehow get nad set user id? 回答1: I believe the save_formset method on ModelAdmin is what you should use: class ArticleAdmin(admin.ModelAdmin): def save_formset(self, request, form, formset, change): instances = formset.save(commit=False) for instance in instances: instance.user = request.user

Django admin - saving inlines overriding save_formset

ε祈祈猫儿з 提交于 2019-12-25 08:53:01
问题 I'm relatively new to django (1.8) and have read around this issue which all points to overriding the save_formset function as per this link https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset Had added to an old thread (Django admin - how to save inlines?) but wanted to raise as a separate thread to get better visibility and besides this already been answered. The function below works where I'm trying to amend the form before saving it, i.e.

WPF C# get the size and position of inline element of a TextBlock

依然范特西╮ 提交于 2019-12-24 11:23:28
问题 I use this example ( https://siderite.dev/blog/how-to-draw-outlined-text-in-wpf-and.html ) for add outline to a text in a TextBlock. However this example don't support Inlines. I try to add this ability modifying the OnRender and I iterate the Inlines collection to build a Geometry for each Inline block. The problem is that I need to get the position and size of the inline block in the TextBlock instead of those of the whole text in the TextBlock. This is the source code that I have modified.

Add row to inlines dynamically in django admin

断了今生、忘了曾经 提交于 2019-12-21 05:41:09
问题 I have the following defined: class AnswerChoiceInline(admin.TabularInline): model = AnswerChoice # extra = 0 class QuestionAdmin(admin.ModelAdmin): inlines = [AnswerChoiceInline] admin.site.register(Question, QuestionAdmin) Obviously I get the default extras setting (default is 3). Is there a way built into the admin currently to 'Add another row' to the inline fieldset? So I can fill in say 3 rows, and if I need a 4th I can click a link or button, and have it add an additional row? Right

Add row to inlines dynamically in django admin

旧街凉风 提交于 2019-12-21 05:41:06
问题 I have the following defined: class AnswerChoiceInline(admin.TabularInline): model = AnswerChoice # extra = 0 class QuestionAdmin(admin.ModelAdmin): inlines = [AnswerChoiceInline] admin.site.register(Question, QuestionAdmin) Obviously I get the default extras setting (default is 3). Is there a way built into the admin currently to 'Add another row' to the inline fieldset? So I can fill in say 3 rows, and if I need a 4th I can click a link or button, and have it add an additional row? Right

Add row to inlines dynamically in django admin

橙三吉。 提交于 2019-12-03 21:16:49
I have the following defined: class AnswerChoiceInline(admin.TabularInline): model = AnswerChoice # extra = 0 class QuestionAdmin(admin.ModelAdmin): inlines = [AnswerChoiceInline] admin.site.register(Question, QuestionAdmin) Obviously I get the default extras setting (default is 3). Is there a way built into the admin currently to 'Add another row' to the inline fieldset? So I can fill in say 3 rows, and if I need a 4th I can click a link or button, and have it add an additional row? Right now my work flow is either set 'extra' to an arbitrarily large number and then just have blank rows or

Django admin different inlines for change and add view

心不动则不痛 提交于 2019-12-03 17:55:48
问题 I need separate views for add and change page. In add page I'd like to exclude some fields from inline formset. I've prepared two TabularInline classes, one of them contains property 'exclude'. I tried to use them as follows: class BoxAdmin(admin.ModelAdmin): def change_view(self, request, obj_id): self.inlines=[ItemChangeInline,] return super(BoxAdmin, self).change_view(self.request, obj_id) def add_view(self, request): self.inlines=[ItemAddInline,] return super(BoxAdmin, self).add_view(self

Making inlines conditional in the Django admin

你说的曾经没有我的故事 提交于 2019-12-03 16:42:50
问题 I have a model that I want staff to be able to edit up to the date for the event. Like this: class ThingAdmin(admin.ModelAdmin): model = Thing if obj.date < today: #Something like that inlines = [MyInline,] The problem is, I don't have access to the obj instance at this level. I've tried overriding get_formset(), but didn't get anywhere. Please advise? 回答1: Thanks to the comments for a change in 1.4. My implementation here wasn't thread safe either, so it really should have been deleted.