How can I hide DTE_Processing_Indicator?

How can I hide DTE_Processing_Indicator?

rshunrshun Posts: 44Questions: 9Answers: 0
edited January 2021 in Free community support

I use dependent() API for my dropdown.

When I use

editor.dependent('Unit', '@Url.Action("UnitsOption")');

DTE_Processing_Indicator show and flashing.  I want to hide it.

I try css

div.DTE_Processing_Indicator {
  display: none;
}

not working?

Then I try adding callback(true) at the end from http://live.datatables.net/vejolizo/1/edit

editor.dependent('Unit', function (val, data, callback) {
            $.ajax({
                url: '@Url.Action("UnitsOption")',
                dataType: 'json',
                success: function (json) {
                    callback(true);
                }
            });
    })

Nothing show up in my dropdown.

Please help me.

Rick

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin

    Hi Rick,

    editor.dependent('Unit', '@Url.Action("UnitsOption")');
    

    should be all that is needed. The processing icon will show up while the Ajax process is happening (to let the user know something is happening) and then hide when the process completes.

    If that isn't happening, something is wrong somewhere. What is the response from the server? Also, are there any errors shown in your browser's console?

    If you can link to the page you are working on I can debug it.

    Regards,
    Allan

  • rshunrshun Posts: 44Questions: 9Answers: 0

    I can show you UnitsOption

            public ActionResult UnitsOption()
        {
            var request = System.Web.HttpContext.Current.Request;
            string siteString = request.Form["values[Site]"];
    
            List<ValueLabelObject> unitList = new List<ValueLabelObject>();
    
            switch (siteString)
            {
                case "ABC":
                    unitList.Add(new ValueLabelObject { label = "A100", value = "A100" });
                    break;
                case "EFG":
                    unitList.Add(new ValueLabelObject { label = "E100", value = "E100" });
                    break;
                case "XYZ":
                    unitList.Add(new ValueLabelObject { label = "X100", value = "X100" });
                    break;
                default:
                    break;
            }
    
            UnitsObject options = new UnitsObject { UnitList = unitList };
            return new JsonNetResult { Data = new { options = options } };
        }
    

    I guess because I don't call database.
    Something like using [var db = new Database()] to fetch data. That is why processing icon show up (don't know ajax process complete).

    Rick

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    If that isn't happening, something is wrong somewhere. What is the response from the server? Also, are there any errors shown in your browser's console?

    Allan is asking you to use the browser's network inspector to look at the response.

    He also asked if you are getting errors in the browser's console.

    The client doesn't know, nor care, if you are using a database or just returning data. If the processing doesn't hide then there is an error in the response.

    Kevin

  • rshunrshun Posts: 44Questions: 9Answers: 0

    This is no error in the browser's console.

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Did you look at the response using the browser's network inspector?

    Kevin

  • rshunrshun Posts: 44Questions: 9Answers: 0
    edited January 2021

    Yes. It is keep calling UnitsOption.

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Yes. It is keep calling UnitsOption.

    Do you mean its in an infinite loop?

    Is there anything in the Response tab? Please post the response here.

    Kevin

  • rshunrshun Posts: 44Questions: 9Answers: 0

    In Google Chrome,

    In Firefox,

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    As Allan asked, are you able to link to your page so we can debug it?

    Colin

  • rshunrshun Posts: 44Questions: 9Answers: 0

    That website is located in internal network. External do not have access to it.

  • rshunrshun Posts: 44Questions: 9Answers: 0

    I also can provide the remain code

    public class UnitsObject
        {
            [JsonProperty("Unit")]
            public List<ValueLabelObject> UnitList { get; set; }
        }
        public class ValueLabelObject
        {
            public string value { get; set; }
            public string label { get; set; }
        }
    
        public class JsonNetResult : ActionResult
        {
            public Encoding ContentEncoding { get; set; }
            public string ContentType { get; set; }
            public object Data { get; set; }
            public JsonSerializerSettings SerializerSettings { get; set; }
            public Formatting Formatting { get; set; }
    
            public JsonNetResult()
            {
                SerializerSettings = new JsonSerializerSettings();
            }
            public override void ExecuteResult(ControllerContext context)
            {
                if (context == null)
                    throw new ArgumentNullException("context");
                HttpResponseBase response = context.HttpContext.Response;
                response.ContentType = !string.IsNullOrEmpty(ContentType)
                  ? ContentType
                  : "application/json";
    
                if (ContentEncoding != null)
                    response.ContentEncoding = ContentEncoding;
                if (Data != null)
                {
                    JsonTextWriter writer = new JsonTextWriter(response.Output) { Formatting = Formatting };
                    JsonSerializer serializer = JsonSerializer.Create(SerializerSettings);
                    serializer.Serialize(writer, Data);
                    writer.Flush();
                }
            }
        }
    
  • rshunrshun Posts: 44Questions: 9Answers: 0

    I don't see any error message in console.

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin

    Can you show me the response from the server please? Click on one of the items in the Network inspector and then "Response" to see what the server is sending back.

    Thanks,
    Allan

  • rshunrshun Posts: 44Questions: 9Answers: 0

    This json back from my server when I call

    editor.dependent('Unit', '@Url.Action("UnitsOption")');

    {
        "options": {
            "Unit": [{
                "value": "A100",
                "label": "A100"
            }, {
                "value": "B100",
                "label": "B100"
            }]
        }
    }
    
  • rshunrshun Posts: 44Questions: 9Answers: 0

    https://editor.datatables.net/reference/api/field().processing()

    I check online documentation. I can use
    editor.field('input1').processing(false);
    to hide DTE_Processing

    How can I use editor.field('input1').processing(false); when I call editor.dependent('Unit', '@Url.Action("UnitsOption")');

  • rshunrshun Posts: 44Questions: 9Answers: 0

    Hi all,

    I know what is wrong with my code. I need to call

    editor.dependent('Site', '@Url.Action("UnitsOption")');

    instead of

    editor.dependent('Unit', '@Url.Action("UnitsOption")');

    Sorry! For the silly mistake. Thank you everyone to help me out.

    Rick

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin
    Answer ✓

    Hi Rick,

    Many thanks for posting back with what you've found. Good to hear you've got it working now!

    Regards,
    Allan

This discussion has been closed.