问题列表 - 第35235页

Jquery提交表单

如何使用以下代码提交特定表单(例如我的表单的ID是#form1).

$(".nextbutton").click(function() { submit; });
Run Code Online (Sandbox Code Playgroud)

forms jquery submit

40
推荐指数
2
解决办法
12万
查看次数

使用Automapper将字符串映射到枚举

我的问题是从已从数据库返回的Linq2Sql对象中保护Viewmodel.我们已经在一些领域做到了这一点并且有一个很好的分层模式,但是最新的项目要求使用一些枚举,这引起了全面的麻烦.目前我们从数据库撤回然后使用Automapper将水合(或变平)到我们的View模型中,但是模型中的枚举似乎导致了Automapper的问题.我已经尝试创建自定义resovler,它已满足我所有其他映射要求,但它在此实例中不起作用.

代码示例如下:

public class CustomerBillingTabView{
    public string PaymentMethod {get; set;}
    ...other details
}

public class BillingViewModel{
    public PaymentMethodType PaymentMethod {get; set;}
    ...other details
}

public enum PaymentMethodType {
    Invoice, DirectDebit, CreditCard, Other
}

public class PaymentMethodTypeResolver : ValueResolver<CustomerBillingTabView, PaymentMethodType>
{
    protected override PaymentMethodType ResolveCore(CustomerBillingTabView source)
    {

        if (string.IsNullOrWhiteSpace(source.PaymentMethod))
        {
            source.PaymentMethod = source.PaymentMethod.Replace(" ", "");
            return (PaymentMethodType)Enum.Parse(typeof(PaymentMethodType), source.PaymentMethod, true);
        }

        return PaymentMethodType.Other;
    }
}

        CreateMap<CustomerBillingTabView, CustomerBillingViewModel>()
        .ForMember(c => c.CollectionMethod, opt => opt.ResolveUsing<PaymentMethodTypeResolver>())
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

[ArgumentException: Type provided must be an Enum.
Parameter …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc enums viewmodel automapper valueinjecter

8
推荐指数
2
解决办法
8336
查看次数

C#程序崩溃

谢谢大家帮我解决1位数和> 31个问题.

现在,最后一件事......如果文本框中包含非数字字符或根本没有字符,程序将崩溃.

这是整个代码:

private void generate_Click(object sender, EventArgs e)
        {
            int val = 0;

            if (Int32.TryParse(dd.Text, out val))
            {
                if (val > 31) return;
                else if (dd.Text.Length <= 1)
                    return;
            }

            if (Int32.TryParse(MM.Text, out val))
            {
                if (val > 31) return;
                else if (MM.Text.Length <= 1)
                    return;
            }

            if (Int32.TryParse(hh.Text, out val))
            {
                if (val > 31) return;
                else if (hh.Text.Length <= 1)
                    return;
            }

            if (Int32.TryParse(M.Text, out val))
            {
                if (val > 31) return;
                else if (M.Text.Length <= …
Run Code Online (Sandbox Code Playgroud)

c#

2
推荐指数
1
解决办法
292
查看次数

如何在Telerik网格中插入下拉列表框

我有一个Telerik Grid,有两列我需要将第二列作为下拉列表框保存在网格中,我正在使用ASP.NET MVC控件

任何人都能告诉我怎么做吗?

asp.net-mvc telerik telerik-grid

1
推荐指数
1
解决办法
1万
查看次数

在使用ConcurrentMap的putIfAbsent之前,你应该检查地图是否包含Key

我一直在使用Java的ConcurrentMap作为可以从多个线程使用的地图.putIfAbsent是一个很好的方法,比使用标准的map操作更容易读/写.我有一些看起来像这样的代码:

ConcurrentMap<String, Set<X>> map = new ConcurrentHashMap<String, Set<X>>();

// ...

map.putIfAbsent(name, new HashSet<X>());
map.get(name).add(Y);
Run Code Online (Sandbox Code Playgroud)

可读性明智这很好,但它确实需要每次创建一个新的HashSet,即使它已经在地图中.我可以这样写:

if (!map.containsKey(name)) {
    map.putIfAbsent(name, new HashSet<X>());
}
map.get(name).add(Y);
Run Code Online (Sandbox Code Playgroud)

通过此更改,它会失去一点可读性,但不需要每次都创建HashSet.在这种情况下哪个更好?我倾向于支持第一个,因为它更具可读性.第二个会表现得更好,也可能更正确.也许有比这两种方法更好的方法.

以这种方式使用putIfAbsent的最佳做法是什么?

java concurrency performance concurrenthashmap

69
推荐指数
3
解决办法
4万
查看次数

变量乘法的优化

[这最初是在矩阵上,但我想它通常适用于任何变量]

说我们有Var1 * Var2 * Var3 * Var4.

其中一个零星地改变,其中一个是随机的.

是否可以最小化乘法?

如果我做

In case Var1 changes: newVar1 * savedVar2Var3Var4
Run Code Online (Sandbox Code Playgroud)

我注意到,每当Var2,Var3,Var4改变时,我需要重新计算savedVar2Var3Var4.

重新计算"已保存的组合"是否会违背目的?

c algorithm math optimization matrix

2
推荐指数
2
解决办法
1151
查看次数

jQuery用新的id克隆一个表,如何集体写下面的代码

我遇到一些jQuery的问题,请帮帮我.以下是我的表单结构:

<form name="imageUploadForm" id="imageUploadForm" action="" method="POST" enctype="multipart/form-data" >
   <table border="0" width="80%" cellpadding="2" cellspacing="3" id="mainTable">
   <tbody>
    <tr>
            <td> 
                  <table border="0" id="imageTable" class="imageTable">
                    <tr>
                      <td><label for="image_title"><sup>*</sup>Image Title:</label></td>
                      <td><input type="text" name="image_title[]" id="image_title[]"></td>
                    </tr>
                    <tr>
                      <td><sup>*</sup>Image:</td>
                      <td><input type="file" name="main_image[]" id="main_image[]" ></td>
                    </tr>
                  </table>
            </td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="2"><input type="button" id="addRow" value="Add More" /></td>
        </tr>
    </tfoot>
    </table>    
</form> 
Run Code Online (Sandbox Code Playgroud)

我想要的是:当我点击Add More按钮时,一个新表(即imagetable的克隆)附加到mainTable,这是我的jQuery代码:

jQuery(document).ready(function() {
    var count=1;
    jQuery('#addRow').click( function () {
        var Clonedtable = jQuery("#imageTable").clone(true);
        Clonedtable.appendTo('table#mainTable');
    })
});
Run Code Online (Sandbox Code Playgroud)
  • 我需要为表和两个输入创建不同的ID
  • 制作一系列ID是否有效?
  • 我想追加克隆表附加tbody的最后一个表,而不仅仅是在主ImageTable之后
  • 两个输入都应为空.

请建议我优化的方法.谢谢.


更新:我已经改变了表结构(之前我错了),我想for …

jquery

1
推荐指数
1
解决办法
2万
查看次数

哪个keyvalue商店有最好的表现?

我想两个月前.我找到了一个谷歌的开源项目,可以存储具有高性能的键值对.但我忘了这个名字.有人可以告诉我吗?或者您可以为我提供一些其他建议?我一直在使用BerkerlyDB,但我发现BerkerlyDb对我的程序来说还不够快.但是,berkerylyDB很方便使用,因为它看起来像一个java lib jar,可以无缝地与我的程序集成.我的程序也是用Java编写的.

java database

5
推荐指数
1
解决办法
4630
查看次数

STLish Radix/Patricia Trie的lower_bound函数

最近我一直在研究Patricia尝试,并使用一个非常好的C++实现,可以用作STL Sorted Associative Container.Patricia尝试与普通二叉树不同,因为叶节点具有指向内部节点的后向指针.尽管如此,如果您只通过叶节点后向指针访问内部节点,则可以通过执行有序遍历来按字母顺序遍历Patricia trie.

这让我想到了一个问题:是否可以用Patricia trie 实现STL lower_boundupper_bound功能?我使用的实施确实事实上,实现这些功能,但预计他们不工作.

例如:

typedef uxn::patl::trie_set<std::string> trie;
trie ts;
ts.insert("LR");
ts.insert("BLQ");
ts.insert("HCDA");

trie::iterator it = ts.lower_bound("GG");
std::cout << *it << std::endl;
Run Code Online (Sandbox Code Playgroud)

这会输出BLQ,当我希望它输出HCDA时.(std::set例如,肯定会在这里输出HCDA.)

我通过电子邮件发送了制作此库的开发人员,但从未收到回复.无论如何,我觉得我非常了解Patricia如何尝试工作,我无法弄清楚low_bound之类的东西是如何可行的.问题是lower_bound似乎依赖于按字母顺序比较两个字符串的能力.由于树中不存在"GG",我们需要找出哪个元素> =到GG.但Radix/Patricia尝试不使用词典比较从一个节点移动到另一个节点; 而是每个节点存储一个比特索引,用于对搜索关键字进行比特比较.位比较的结果告诉您是向左还是向右移动.这样可以很容易地在树中找到特定的前缀.但是如果树中不存在前缀,

我正在使用的C++实现似乎没有正确实现lower_bound的事实证实了我怀疑它可能是不可能的.尽管如此,你可以按字母顺序迭代树,这让我觉得可能有办法做到这一点.

有没有人有这方面的经验,或者知道是否可以用Patricia Trie实现lower_bound功能?

c++ stl trie patricia-trie

8
推荐指数
1
解决办法
1324
查看次数

jquery数据表更新单元格

我有一个表格,如:

<table id="myTable">
  <thead>
    <tr>
      <td><input type="checkbox" id="selectall" /></td>
      <td>Column 1</td>
      <td>Column 2</td>
      <td>Column 3</td>
      <td>Column 4</td>
      <td>Column 5</td>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

然后,javascript:

var myTable = jQuery('#myTable').dataTable({
    /* options */
});

// Ajax request to populate:
jQuery.get('script.php', function(data){
    eval("rows="+data);
    for(var i=0;i<rows.length;i++){
        myTable.fnAddData([
          "<input type=\"checkbox\" id=\""+rows[i].uniqueID+"\" />",
          rows[i].col1Txt,
          rows[i].col2Txt,
          rows[i].col3Txt,
          rows[i].col4Txt,
          rows[i].col5Txt ]);
    }
});
Run Code Online (Sandbox Code Playgroud)

现在,我在根据选中的复选框更新表时遇到问题:

我正在尝试更新已检查的每一行中的第5个单元格.我正在使用fnUpdatefnGetPosition(http://www.datatables.net/api)的组合.

fnGetPosition期待tdor tr元素,所以我想我只是抓住td了复选框的父级:

var checkBoxes = jQuery('td > input:checked', myTable);
for(var …
Run Code Online (Sandbox Code Playgroud)

jquery datatables

2
推荐指数
1
解决办法
2万
查看次数