Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1074349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:06:44+00:00 2026-05-16T21:06:44+00:00

I am using jlinq a library for extending linq to json and hence i

  • 0

I am using jlinq a library for extending linq to json and hence i filter my json data. Consider i have a json data that draws a yui datatable on page load with 100 rows. I am doing a clientside filter which will reduce my json data and i am now redrawing the same datatable. What happens is it works pretty well but with an annoying flickering effect…

I call the below method from onkeyup event of the filter textbox,

function showusersfilter(txt) {
    var jsondata = document.getElementById("ctl00_ContentPlaceHolder1_HfJsonString").value;
    jsondata = jQuery.parseJSON(jsondata);
    var results = jLinq.from(jsondata.Table)
                 .startsWith("name", txt)
                 .select();
    var jsfilter = { "Table": results };

    var myColumnDefs = [
         { key: "userid", label: "UserId", hidden: true },
         { key: "name", label: "Name", sortable: true, sortOptions: { defaultDir: YAHOO.widget.DataTable.CLASS_DESC} },
         { key: "designation", label: "Designation" },
         { key: "phone", label: "Phone" },
         { key: "email", label: "Email" },
         { key: "role", label: "Role", sortable: true, sortOptions: { defaultDir: YAHOO.widget.DataTable.CLASS_DESC} },
         { key: "empId", label: "EmpId" },
         { key: "reportingto", label: "Reporting To", sortable: true, sortOptions: { defaultDir: YAHOO.widget.DataTable.CLASS_DESC} },
         { key: "checkbox", label: "", formatter: "checkbox", width: 20 }
     ];
    var jsonObj = jsfilter;
    var target = "datatable";
    var hfId = "ctl00_ContentPlaceHolder1_HfId";
    generateDatatable(target, jsonObj, myColumnDefs, hfId);
}

My textbox looks

<asp:TextBox ID="TxtUserName" runat="server" CssClass="text_box_height_14_width_150" onkeyup="showusersfilter(this.value);"></asp:TextBox>

and my generatedatatable function,

function generateDatatable(target, jsonObj, myColumnDefs, hfId) {
    var root;
    for (key in jsonObj) {
        root = key; break;
    }
    var rootId = "id";
    if (jsonObj[root].length > 0) {
        for (key in jsonObj[root][0]) {
            rootId = key; break;
        }
    }
    YAHOO.example.DynamicData = function() {
        var myPaginator = new YAHOO.widget.Paginator({
            rowsPerPage: 25,
            template: YAHOO.widget.Paginator.TEMPLATE_ROWS_PER_PAGE,
            rowsPerPageOptions: [10, 25, 50, 100],
            pageLinks: 10
        });

        // DataSource instance 
        var myDataSource = new YAHOO.util.DataSource(jsonObj);
        myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
        myDataSource.responseSchema = { resultsList: root, fields: new Array() };
        myDataSource.responseSchema.fields[0] = rootId;
        for (var i = 0; i < myColumnDefs.length; i++) {
            myDataSource.responseSchema.fields[i + 1] = myColumnDefs[i].key;
        }
        // DataTable configuration 
        var myConfigs = {
            sortedBy: { key: myDataSource.responseSchema.fields[1], dir: YAHOO.widget.DataTable.CLASS_ASC }, // Sets UI initial sort arrow
            paginator: myPaginator
        };
        // DataTable instance 
        var myDataTable = new YAHOO.widget.DataTable(target, myColumnDefs, myDataSource, myConfigs);
        myDataTable.resizeHack = function()
        { this.getTbodyEl().parentNode.style.width = "100%"; }
        myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow);
        myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);
        myDataTable.subscribe("rowClickEvent", myDataTable.onEventSelectRow);
        myDataTable.subscribe("checkboxClickEvent", function(oArgs) {
            var hidObj = document.getElementById(hfId);
            var elCheckbox = oArgs.target;
            var oRecord = this.getRecord(elCheckbox);
            var id = oRecord.getData(rootId);
            if (elCheckbox.checked) {
                if (hidObj.value == "") {
                    hidObj.value = id;
                }
                else {
                    hidObj.value += "," + id;
                }
            }
            else {
                hidObj.value = removeIdFromArray("" + hfId, id);
            }
        });
        myPaginator.subscribe("changeRequest", function() {

            if (document.getElementById(hfId).value != "") {
                if (document.getElementById("ConfirmationPanel").style.display == 'block') {
                    document.getElementById("ConfirmationPanel").style.display = 'none';
                }
                document.getElementById(hfId).value = "";
            }
            return true;
        });
        myDataTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
            oPayload.totalRecords = oResponse.meta.totalRecords;
            return oPayload;
        }
        return {
            ds: myDataSource,
            dt: myDataTable
        };
    } ();
}

EDIT:

I even used a delay on the keyup event still the flickering occurs,

var timer;
    function chk_me(){
       clearTimeout(timer);
       timer = setTimeout(function validate(){ showusersfilter(document.getElementById("ctl00_ContentPlaceHolder1_TxtUserName").value);}, 1000);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:06:44+00:00Added an answer on May 16, 2026 at 9:06 pm

    Why do you create a new dataTable each time you filter your data ? You do not need this task. Just supply The filtered data to its dataTable by using sendRequest method of its dataSource

    I have create this jsonObject To simulate filtered data

    var jsonObject = {
        "root":[
            {id:"5", userid:"1", name:"ar", designation:"1programmer", phone:"15484-8547", email:"1arthurseveral@yahoo.com.br", role:"1developer", empId:"1789", reportingto:"116"},
            {id:"5", userid:"2", name:"br", designation:"2programmer", phone:"25484-8547", email:"2arthurseveral@yahoo.com.br", role:"2developer", empId:"2789", reportingto:"216"},
            {id:"5", userid:"3", name:"cr", designation:"3programmer", phone:"35484-8547", email:"3arthurseveral@yahoo.com.br", role:"3developer", empId:"3789", reportingto:"316"},
            {id:"5", userid:"4", name:"dr", designation:"4programmer", phone:"45484-8547", email:"4arthurseveral@yahoo.com.br", role:"4developer", empId:"4789", reportingto:"416"},
            {id:"5", userid:"5", name:"er", designation:"5programmer", phone:"55484-8547", email:"5arthurseveral@yahoo.com.br", role:"5developer", empId:"5789", reportingto:"516"}
        ],
        "another":[
            {id:"5", userid:"5", name:"er", designation:"5programmer", phone:"55484-8547", email:"5arthurseveral@yahoo.com.br", role:"5developer", empId:"5789", reportingto:"516"},
            {id:"5", userid:"4", name:"dr", designation:"4programmer", phone:"45484-8547", email:"4arthurseveral@yahoo.com.br", role:"4developer", empId:"4789", reportingto:"416"},
            {id:"5", userid:"3", name:"cr", designation:"3programmer", phone:"35484-8547", email:"3arthurseveral@yahoo.com.br", role:"3developer", empId:"3789", reportingto:"316"},
            {id:"5", userid:"2", name:"br", designation:"2programmer", phone:"25484-8547", email:"2arthurseveral@yahoo.com.br", role:"2developer", empId:"2789", reportingto:"216"},
            {id:"5", userid:"1", name:"ar", designation:"1programmer", phone:"15484-8547", email:"1arthurseveral@yahoo.com.br", role:"1developer", empId:"1789", reportingto:"116"}
        ]
    };
    

    When initializing

    (function() {
        var Yutil      = YAHOO.util,
            Ywidget    = YAHOO.widget
    
            DataTable  = Ywidget.DataTable,
            Paginator  = Ywidget.Paginator,
            DataSource = Yutil.DataSource;
    
        YAHOO.namespace("_3657287"); // QUESTION ID - SEE URL
    
        var _3657287 = YAHOO._3657287;
    
        /**
          * paginator
          */
        var paginator = new Paginator({
            rowsPerPage:25,
            template:Paginator.TEMPLATE_ROWS_PER_PAGE,
            rowsPerPageOptions:[10, 25, 50, 100],
            pageLinks:10
        });
    
        /**
          * dataSource
          *
          * As you have static data, I pass an empty "jsonObject" to its constructor
          */
        var dataSource = new DataSource({root:[]});
        dataSource.responseType = DataSource.TYPE_JSON;
        dataSource.responseSchema = {resultsList:"root", fields:[]};
    
        var columnSettings = [
            {key:"userid", label:"UserId"},
            {key:"name", label:"Name"},
            {key:"designation", label:"Designation"},
            {key:"phone", label:"Phone"},
            {key:"email", label:"Email"},
            {key:"role", label:"Role"},
            {key:"empId", label:"EmpId"},
            {key:"reportingto", label:"Reporting To"}
        ];
    
        dataSource.responseSchema.fields[0] = "id";
        for (var i = 0; i < columnSettings.length; i++) {
            dataSource.responseSchema.fields[i + 1] = columnSettings[i].key;
        }
    
        /**
          * Notice initialLoad equal To false (I suppose your dataTable IS NOT pre-populated)
          */
        var dataTableSettings = {
            paginator:paginator,
            initialLoad:false
        };
    
        /**
          * dataTable
          *
          * Notice IT IS STORED in the namespace YAHOO._3657287
          */
        _3657287.dataTable = new DataTable("container", columnSettings, dataSource, dataTableSettings);
    })();
    

    Now when you want to filter your data, do as follows (Notice sendRequest method)

    var i = 0;
    YAHOO.util.Event.addListener("reload", "keyup", function(e) {
        YAHOO._3657287.dataTable.getDataSource().sendRequest(null, {
            success:function(request, response, payload) {
    
                /**
                  * initializeTable method clear any data stored by The datatable
                  */
                this.initializeTable();
    
                if(i === 0) {
                    this.getRecordSet().setRecords(jsonObject["root"], 0);
    
                    i++;
                } else {
                    this.getRecordSet().setRecords(jsonObject["another"], 0);
    
                    i--;
                }
    
                this.render();
            },
            scope:YAHOO._3657287.dataTable,
            argument:null
        });
    });
    

    You can see here. It works fine!

    But if the effect appears again (Notice i am just using relevant part – Nor special feature Nor something else) can occurs because

    • keyup Event
    • dataTable rendering

    You can set up a variable as follows

    var isProcessing = false;
    
    YAHOO.util.Event.addListener("reload", "keyup", function(e) {
        if(isProcessing) {
            return;
        }
    
        isProcessing = true;
    
        YAHOO._3657287.dataTable.getDataSource().sendRequest(null, {
            success:function(request, response, payload) {
                 // as shown above
    
                 isProcessing = false;
            }
        });
    }
    

    See also here and here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using C#, I need a class called User that has a username, password, active
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
Using JDeveloper , I started developing a set of web pages for a project
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.