Make input field small? - django

I have a form based on a model. I create a modelformset and need to display many (possibly hundreds) of individual form fields on a single page. I need to reduce the input size and am achieving this by using this:
widgets = {
'm1_pf': forms.TextInput(attrs={'size':1}),
}
However, this smallest size of 1 is still too big. Is there some other way of accomplishing a data-grid like presentation?
I have looked at using a Datatable with "editable cells" but this will not work for my situation. I need to be able to enter several values quickly by entering the first value, hitting tab, entering the next value, hitting tab, etc. Using the mouse to "click" into each cell and edit it (as is how Datatables works) is out of the question.
Thanks

Nevermind -- I figured it out. I added this to my CSS sheet:
input {
width: 1px;
}
I am OK with all input tags having this value.

Related

How to do dynamic paging in Grid.MVC

I have using grid.mvc control in my project. I want to use dynamic paging in grid.mvc control.
I have combobox having entries 10,25,50. when I change comboBox value. Grid should display data accordingly. ( E.g. when I select 25, grid will show 25 rows). by deafult grid is showing 10 rows at a time.
Also it should adjust while filtering records.
I tried but didn't found any suitable solution.
This in theory should be pretty easy though I haven't done it myself.
You can link that dropdown (in the view) to an action result (in the controller) that changes a value you pass to the ViewBag (in controller ViewBag.WhateverName = dropdown's value).
Then re-render the same view and in the place when you end your grid, end it with
}).WithPaging(ViewBag.WhateverName)
Basically .WithPaging(10) would give you pages with 10 rows, WithPaging(20) 20 rows per page, etc. So by changing that value with the dropdown and registering that action in the controller to reassign the value, you should be able to achieve this functionality.
I will keep editing and maybe add controller code later if I have time, just wanted to get something up to help you out. Good luck!

Can i change an item in a list from another list?

I´ve created a list in SharePoint. What i´ll like to do is create another list, and retrieve some information from one list to my new one, and be able to change the input data from list A in a single line of text.
So lets say, list A is PopStar, with columns like Genre "Rock", HairColor "Red" and GrammyCount "2".
In list B i only want textboxes to show whats in list A and be able to change (update) them, for example Genre to "Pop", HairColor to "Black" and GrammyCont to "8" ?
Is this possible?
i´m using office 365
In order to achieve exactly what you want you will require either a Workflow or an Event Receiver, however I assume you won't feel confident by struggling with such approaches, furthermore, there are some workarounds that could be very close to your requirement and maybe are even better solutions than the approach you suggest, in terms of maintenance, growth and upgrade.
I suggest to review topics like "SharePoint parent/child list webparts connections" or "sharepoint edit form add child items", here are two videos of which you can get some ideas.
https://www.youtube.com/watch?v=9PWIxk6rF-A
https://www.youtube.com/watch?v=-5CdjfLONgE
Take in count that you can do more than what is displayed in the videos, by example in the Edit Form you could add a webpart to display the Quick Edit View (Grid View) of the related list so the values can be edited in the same Form and thus removing the need to navigate to a second window.

Qt - creating a complex "calculator"

I am building an application that requires a graphical interface for a calculation process.
The calculation is basically a formula written by the user to be evaluated with QScriptEngine - ie, Javascript.
The thing is I'm having trouble breaking down the problem into smaller steps. The general objectives are as follows:
The values that are to be used in a formula report to properties of items. The items are already created and have a list of properties with which I populate a QTableWidget.
By dragging/droping from the table to a QTextEdit, I'm creating a string with some rich-formating to help the users read the formula more intuitively. Basically, each item on the table has a certain color, so in the QTextEdit, when an item is dropped, it gets a background-color formatting with the same color, and displays the property's name; something like: <span style='background-color:red;'> propertyName </span>
The drag/drop interface as well as the formating is coded and working as expected. But now I have a few problems:
some items have properties with the same name. If I create the formula with two different properties (from different items) that have the same name, I can't track the property's value backwards without ambiguity - I was thinking of string compare/string replace the property's name with its value and then calculate with evaluate().
I have been breaking my head on how to get around this and I thought of creating a QMultiMap to hold the item: [property, value] relationships, and then, replacing on the string that will be evaluated. But again, I would need to check form which item the property came from, and I don't know how I can do that.
I'm new to Qt/C++ and I know that most of my code has some big faulty practices, and its being done more in the way of hacking my way through the objectives I require, more than building a good structure - so every new problem gets a more complex solution each time.
Even so, how would you suggest I should tackle this problem? By this time I think it is better to not post my code just yet, because it is too long (and probably painful) to look at. If someone requires a specific portion to better understand the context of the problem, let me know and I'll post here.
Also, I have had other question here in SO when I started to think about this - might be useful to check for context: here.
UPDATE:
In reply to #Riateche's comment:
Imagine this scenario:
Item A : [property1, value1]
[property2, value2]
Item B : [property1, value3]
[property2, value4]
Now, imagine the user wants to perform ItemA.property1 * ItemB.property1:
I want him to see property1 * property1 - but notice that the background-color of each should be different;
I could place in the QTextEdit something like: <span style='background-color:red;'> property1 </span> * <span style='background-color:blue;'> property1 </span>
what I actually want to evaluate (to calculate) is: value1 * value3 - in which these represent double types.
UPDATE 2
After thinking a little bit about this, while #Riateche's approach seems simple, I wasn't able to find a way change a tag's attribute (at least in rich text, maybe there is one with QWebkit, but that is not what I need). So I was thinking if building another string (that will be evaluated), at the same time the user builds a string with drag and drop. For instance, let's imagine the user drags and drops something like:
property1 * property1
At the same time I would build other string that contained
value1 * value3
And this would be the evaluated string. Even so, the problem with the user editing the string would still be there - if the user changes the drag/drop string, I need to update the evaluation string again -requiring me to once again check the origin of the data. Any other ideas?
You should put all information important for the formula evaluation to the text edit. You can make it invisible to user. For example, you can put the following to the text edit:
<span style='background-color:red;'><a name='Item A,property1'></a>property1</span>
The Item A,property1 text will be invisible to user, but textEdit->toHtml() result will contain it.

How to create an image slideshow in an xe:Dialog?

I am trying to create a slideshow in an xe:dialog
within the dialog I have repeat populated from a notesdocumentcollection containing one image for each document. and two buttons. Next and Previous
When the user in the dialog click "Next" the next image in my collection should be displayed and when I click previous the previous image in my collection should be displayed.
As these images can be very big I do not want to preload them, the actual image should be retrieved at the time when the user click the "Next" button.
How can I do this?
the problem I have is that I do not know how to navigate to the next image. there is probably a very simple solution. I have tried using different techniques like setRowIndex and setIndex etc.
I first thought I could set the repeats repeat limit to "1" and then navigate to next by incrementing the index but could not get that to work.
So what I thought about then was to set the repeat limit to 1000 and hide all images using css but then all images would be preloaded.
Instead of document collection, you can store document id's in a vector and put it into viewscope. You also put a current index in the viewScope. Next/previous will change index variable and since xe:dialog supports partial refresh, it will be easy and convenient.

Django add text via button click

Using Django, I want to store a list of textfields that is initially empty but when you click a button it will add a text field. a good example is the add attachment in email, except instead of adding files i just want to add textfields.
Then once I have this feature setup I would like to be able to add all textfields into one textfield to allow a user to edit all textfields at one time, then parse them back into the original text field.
is this possible?
Thank you
cooper
If you don't need to add an unlimited number of inputs, my recommendation would be to use the combination of a custom MultiValueField and MultiWidget, and show/hide the fields you might want to initially hide.
You'll be able to leverage the built-in compress and decompress methods to take the values and split them back out to individual inputs (you'd have to split the text on a delimiter) and then take the separate values and compress them back into one.
If you need to be able to add an unlimited number of fields, and parse them back into one value, I would use a formset to hold the values, which you can concatenate the values of back into another field if you need, or just show in a loop, if all you need is to display them as if they were one field.