How to disable the nop-editor?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi,
How can I disable the text from being edited? I tried using the asp-disabled="true" but it's not working. v4.20

<div class="form-group">
  <div class="col-md-3">
    <nop-label asp-for="VendorId" />
  </div>
  <div class="col-md-9">
    <nop-editor asp-for="VendorId" asp-disabled="true" />
  </div>
</div>
4 years ago
Unfortunately asp-disabled will not work with integer type properties. You have use input instead of nop-editor.
<input asp-for="VendorId" disabled >


If you want it to looks like default design, use this code.
<input asp-for="VendorId" disabled>
<script>
    $(document).ready(function() {
        $("#@Html.IdFor(x => x.VendorId)").TouchSpin({
            min: -2147483648,
            max: 2147483647,
            decimals: 0,
            verticalbuttons: true,
            verticalupclass: "glyphicon glyphicon-chevron-up",
            verticaldownclass: "glyphicon glyphicon-chevron-down",
            buttondown_class: "btn",
            buttonup_class: "btn",
            postfix: ""
        });
    });
</script>
4 years ago
Thanks! this answered my question. Although I have follow up issue.

https://imgur.com/1SVCKGY

The only problem here is if I have that field disabled, and if I try to edit and save (pop up window form) with the vendorId in it, the current value of vendorId is not passing it to the model.
Hope this make sense.

        public IActionResult EditRateByWeightByTotalPopup(ShippingByWeightByTotalModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
                return AccessDeniedView();

            var sbw = _shippingByWeightService.GetById(model.Id);
            if (sbw == null)
                //no record found with the specified id
                return RedirectToAction("Configure");

            sbw.VendorId = model.VendorId; // Value should be 1
            sbw.StoreId = model.StoreId;
            sbw.WarehouseId = model.WarehouseId;
            sbw.CountryId = model.CountryId;
            sbw.StateProvinceId = model.StateProvinceId;
            sbw.Zip = model.Zip == "*" ? null : model.Zip;
            sbw.ShippingMethodId = model.ShippingMethodId;
            sbw.WeightFrom = model.WeightFrom;
            sbw.WeightTo = model.WeightTo;
            sbw.OrderSubtotalFrom = model.OrderSubtotalFrom;
            sbw.OrderSubtotalTo = model.OrderSubtotalTo;
            sbw.AdditionalFixedCost = model.AdditionalFixedCost;
            sbw.RatePerWeightUnit = model.RatePerWeightUnit;
            sbw.PercentageRateOfSubtotal = model.PercentageRateOfSubtotal;
            sbw.LowerWeightLimit = model.LowerWeightLimit;

            _shippingByWeightService.UpdateShippingByWeightRecord(sbw);
4 years ago
Disabled field isn't sent when submit. So instead of disabled, make it readonly.
3 years ago
How do you set readonly?

IE this i not working.

<nop-editor asp-for="MyField" readonly="true" />
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.