1

コンテキスト: を使用して並べ替えを行っていSortableます。

   $("#sortable").sortable({
       update: function (e,ui) 
       {
         nextItemPrio=parseFloat(ui.item.next().find("input[name='Priority']").val().replace(",", "."));
         prevItemPrio = parseFloat(ui.item.prev().find("input[name='Priority']").val().replace(",", "."));
         currentItemPrio = parseFloat(ui.item.find("input[name='Priority']").val().replace(",", "."));
                   if ((nextItemPrio < currentItemPrio && prevItemPrio < currentItemPrio)
          || (nextItemPrio > currentItemPrio && prevItemPrio > currentItemPrio)) {

                    ui.item.find("input[name='Priority']").val((prevItemPrio + nextItemPrio) / 2.0);


                }

コントローラーには次のものがあります:

    public ActionResult UpdatePicturePriority(int id, string newpriority)
      {
        var a = _PictureRepo.GetById(id);
        decimal convertDecimal = Convert.ToDecimal(newpriority.Replace(".", ","),);
        a.Priority = convertDecimal;
        _PictureRepo.Update(a);
        return Json(true);
    }

いくつかの並べ替え (ダイビング) の後、次のような数値が得られますが、値をコントローラー (MVC アプリケーション) に投稿 0,0023565すると変換されるようです。0私のコードはいくつかの分割後に機能しないため、これは望ましくありません。数字が四捨五入されたくない。

4

1 に答える 1