在完成Django教程之后,我现在正在尝试构建一个非常简单的开票应用程序.
我想在发票中添加几个产品,并在Django管理员的发票表单中指定每个产品的数量.现在,如果我有相同产品的不同数量,我将创建一个新的Product对象.
现在我的模型看起来像这样(公司和客户模型遗漏了):
class Product(models.Model):
description = models.TextField()
quantity = models.IntegerField()
price = models.DecimalField(max_digits=10,decimal_places=2)
tax = models.ForeignKey(Tax)
class Invoice(models.Model):
company = models.ForeignKey(Company)
customer = models.ForeignKey(Customer)
products = models.ManyToManyField(Product)
invoice_no = models.IntegerField()
invoice_date = models.DateField(auto_now=True)
due_date = models.DateField(default=datetime.date.today() + datetime.timedelta(days=14))
Run Code Online (Sandbox Code Playgroud)
我想数量应该从产品模型中排除,但如何在发票模型中为其创建一个字段?
我已经为这个问题苦苦挣扎了两天,非常感谢任何帮助。我有一个剑道网格,其中我给了网格 excel 一样的功能,即在点击输入时,可编辑的列被突出显示,我可以输入值,并在选项卡上移动到下一个单元格。我有一个名为 external amount 的列是可编辑的,即用户在单元格中输入值,下一列是差异,每当用户在外部金额列中输入一个值并点击回车时,就应该计算该差异。
差异-InternalLocalAmt-ExternallocalAmt。InternalLocalAmt 已填充且不可编辑。
代码片段:
@(Html.Kendo().Grid(Model)
.Name("OutputCashGrid")
.Columns(columns =>
{
columns.Bound(p => p.InternalLocalAmt).Width(130);
columns.Bound(p => p.ExternalLocalAmt).Width(130);
columns.Bound(p => p.LocalDifference).Title("Difference").Width(130).Format("{0:N}").HtmlAttributes(new{id="DifferenceVal"});
})
.Sortable()
.ColumnMenu()
.Scrollable(scr => scr.Height(430))
.Filterable()
.Navigatable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(50)
.ServerOperation(false)
.Batch(true) // Enable batch updates.
.Model(model =>
{
model.Id(p => p.OutputcashID); // Specify the property which is the unique identifier of the model.
//model.Field(p => p.OutputcashID).Editable(false); // Make the ProductID property not editable.
model.Field(p => p.OutputcashID).Editable(false);
model.Field(p => p.Level1).Editable(false);
model.Field(p => p.TotalRecitems).Editable(false);
model.Field(p …Run Code Online (Sandbox Code Playgroud) jquery inline-editing asp.net-mvc-4 kendo-grid kendo-asp.net-mvc
我有一堆包含半标准头文件的文件.也就是说,它的外观非常相似,但文字有些变化.
我想从所有文件中删除此标头.
从查看文件,我知道我要删除的内容是封装在相似的单词之间.
所以,例如,我有:
Foo bar...some text here...
more text
Foo bar...I want to keep everything after this point
Run Code Online (Sandbox Code Playgroud)
我在perl中尝试了这个命令:
perl -pi -e "s/\A.*?Foo.bar*?Foo.bar//simxg" 00ws110.txt
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我不是一个正则表达式专家,但希望有人知道如何基于文本匹配而不是字符数从文件的开头基本上删除一大块文本...
添加了tinyMCE作为内联编辑器.有一个下一个问题:第一次这是好的工作 - 显示自定义样式(如我设置),工作正常,但当我单击取消然后再次开始编辑我有空编辑器 - 编辑区域没有文本.所以这是一个代码:UPD:cm.Node - docuement.createElement和el.setAttribute的包装器,cm.getByAttr('attr','attr_val',el) - 来自el的attr得到elemnt.req - AJAX的包装器,cm.merge - 类似于PHP中的array_merge
var EditBlock = function(){
var my = this;
var o = cm.merge({
'id' : '',
'act' : '',
'val' : '',
'nobr' : false,
'text' : false,
'onSaved' : function(){},
'onSave' : function(){},
'params' : {'iconsPath' : 'interface/common/images/stdc/nicEditorIcons.gif'}
}, arguments[0]);
var prefix = 'tinyMCE_' + Math.random() + '_';
var node = cm.getEl(o.id);
var txtArea = cm.addClass(cm.Node('textarea', {'id' : prefix + o.id, 'style': ('width:' + node.offsetWidth + 'px')}), …Run Code Online (Sandbox Code Playgroud) 我使用best_in_place gem来编辑内联和country_select记录,以呈现可供选择的国家列表.使用best_in_place编辑选择字段时,我这样做:
<%= best_in_place(@home, :country_name, :type => :select, :collection => [[1, "Spain"], [2, "Italy"]]) %>
Run Code Online (Sandbox Code Playgroud)
现在,我想获得country_select所有国家/地区的列表,并将其传递到collection参数中.country_select gem提供了一个简单的帮助器来呈现select字段:
<%= country_select("home", "country_name") %>
Run Code Online (Sandbox Code Playgroud)
我想替换best_in_place帮助器中的:collection参数,以包含country_select提供的国家列表.我知道best_in_place期望[[key,value],[key,value],...]输入:collection,但我不知道如何做到这一点.请指教.谢谢
我一直在尝试在jQuery Datatable中实现简单的内联编辑.但我无法激活点击行单元格时发生的编辑.我使用与其网站链接相同的代码:
<table id="Datatable" cellpadding="0" cellspacing="0" border="0" class="display">
<thead>
<tr>
<th>Age</th>
<th>Name</th>
</tr>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
数据绑定:
/* Init DataTables */
var oTable = $('#Datatable').dataTable({
"bProcessing": true,
"sAjaxSource":"http://localhost:6220/DataSources/WCF/Data.svc/GetCustomer",
"aoColumns": [
{ "mDataProp": "Age" },
{ "mDataProp": "Name" }
]
});
/* Apply the jEditable handlers to the table */ oTable.$('td').editable('http://localhost:6220/DataSources/WCF/Data.svc/SaveCustomer', {
tooltip: 'Click to edit...',
"callback": function (sValue, y) {
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue, aPos[0], aPos[1]);
},
"submitdata": function (value, settings) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition(this)[2] …Run Code Online (Sandbox Code Playgroud) 我试图编写内联编辑功能而不使用此处概述的模板 http://plnkr.co/edit/EsW7mV?p=preview
基本上我试图使用ajax概念来玩编辑功能.
大家都知道,我现在处于起步阶段,现在我从这个网址下载了一些代码. http://vitalets.github.io/x-editable/docs.html
我的代码在这里
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ajax Edit using PHP</title>
<link href="bootstrap.min.css" rel="stylesheet">
<link href="bootstrap-editable.css" rel="stylesheet">
<script src="jquery-2.0.3.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="bootstrap-editable.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#username').editable({
type: 'text',
url: 'post.php',
title: 'Enter username'
});
});
</script>
</head>
<body>
<?php
mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
$result = mysql_query("SELECT * FROM books") or die(mysql_error());
?>
<div style="margin-top:100px;margin-left:40px;">
<?php while($row = mysql_fetch_array( $result )) { ?>
<a href="#" data-pk="<?php echo $row['book_id']; ?>" id="username"><?php echo $row['book_name']; …Run Code Online (Sandbox Code Playgroud) 我的两个最高优先级是渐进增强和内联编辑.我发现了渐进增强(DataTables)和内联编辑(jqGrid),但不是两者都有.支持jQuery UI主题会很不错,但优先级较低.
更新:这是我想象的解决方案类似的例子:
<table summary="A table full of example tabular data">
<caption>My Table to Progressively Enhance</caption>
<thead>
<tr>
<th id="colA">Column A</th>
<th id="colB">Column B</th>
</tr>
</thead>
<tbody>
<tr>
<td headers="colA">foo</td>
<td headers="colB">bar</td>
</tr>
<tr>
<td headers="colA">argle</td>
<td headers="colB">bargle</td>
</tr>
</tbody>
</table>
… insert jquery datatable stuff here …
<script type="text/javascript">
progressivelyEnhanceMyTable();
</script>
Run Code Online (Sandbox Code Playgroud) jquery yui html-table progressive-enhancement inline-editing
我想执行一个热键,删除powershell会话中的当前行.这样的事情可能吗?
我的页面中有以下HTML
<div id='divContainer1' onmouseover=ShowEditDiv(1) onmouseout=HideEditDiv(1) class='divClcContainer'>
<div id='divSlNo1'>1</div>
<div id='divItem1'>This is content</div>
<div id='divEditLink1'></div>
</div>
<div id='divContainer2' onmouseover=ShowEditDiv(2) onmouseout=HideEditDiv(2) class='divClcContainer'>
<div id='divSlNo2'>2</div>
<div id='divItem2'>This is content2</div>
<div id='divEditLink2'></div>
</div>
Run Code Online (Sandbox Code Playgroud)
并在我的JavaScript中
function ShowEditDiv(divId)
{
$("#divEditLink" + divId).html("<a href=\"javascript:Edit(divId)\"><img src='edit_icon.gif' alt='Edit' title='Edit' /></a>").addClass("divEdit");
}
function HideEditDiv(divId)
{
$("#divEdit" + divId).empty().addClass('divEdit');
}
Run Code Online (Sandbox Code Playgroud)
我的要求是当用户将鼠标放在主div上时显示编辑链接.现在它的工作正常.但是当我将鼠标放在保存编辑图像/链接的div上时,它正在消失.我发现当我将鼠标放在编辑div上时,父div的mouseout函数被调用.任何人都可以帮我解决这个问题吗?
inline-editing ×12
jquery ×4
javascript ×2
angularjs ×1
console ×1
datagrid ×1
datatables ×1
django ×1
django-admin ×1
html-table ×1
kendo-grid ×1
knockout.js ×1
mouseover ×1
mysql ×1
perl ×1
php ×1
powershell ×1
python ×1
regex ×1
text ×1
tinymce ×1
x-editable ×1
yui ×1