Nov 15, 2017

[Solution] How to empty a data grid in jeasyui ?

Question :

I have a data grid with 1000 records when i perform a search on a table, i need to remove all records in the data grid when i call a method, how can i do that ?

Answer :

1. We could load an empty data set to the data grid.
    $('#dg').datagrid('loadData', {"total":0,"rows":[]});

2. We could remove only the selected records in the data grid.

var rows = $('#tt').datagrid('getSelections');  // get all selected rows
for(var i=0; i<rows.length; i++){
var index = $('#tt').datagrid('getRowIndex',rows[i].id);  // get the row index
$('#tt').datagrid('deleteRow',index);
}


Apr 12, 2017

SQL Server Get The Alpha Numeric Text Only From A Column

Lets say there is column with special characters and all. Will say you just want to filter and take the Alpha Numeric Text Only. This scenario comes normally when you want to find duplicate records, just like my case.

In this case you can simply right a SQL Function to filter the text.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
CREATE Function [dbo].[GetAlphanumericTextOnly](@Temp VarChar(1000))
Returns VarChar(1000)
AS
Begin

    Declare @KeepValues as varchar(50)
    Set @KeepValues = '%[^a-z0-9]%'
    While PatIndex(@KeepValues, @Temp) > 0
        Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '')

    Return @Temp
End

Then call the function


1
SELECT [dbo].[GetAlphanumericTextOnly]('Nifal.Nizar1990@Hotmail.com')

You will get the result as NifalNizar1990Hotmailcom

Jan 26, 2017

[Solution] Call Method Once Flip Is Done - jQuery-Flip

Question

 am using a Flip Plugin
I have been trying to call a method once the flip is done/completed, but the method is getting called even before the flip is done.completed.
$("#card").flip('toggle');
$("#card").on("done", ChangeWord());
Let me know where i am going wrong ?
Answere 
Your answer is in the link you posted in the question under the 'Events' heading. Specifically, the flip:done event. Also note that you need to pass the reference of the ChangeWord() function to the event handler, not its return value. Try this:
$("#card").on('flip:done', ChangeWord).flip('toggle');
Alternatively the flip() method accepts a callback function to be executed when the animation completes:
$("#card").flip('toggle', ChangeWord);

$("#card").flip('toggle', ChangeWord); this worked out fine as this will happen only when i use it , but $("#card").on('flip:done', ChangeWord).flip('toggle'); will call the method every time it flips 

Jan 22, 2017

[Solution] jQuery: How to capture the TAB keypress within a Textbox

Problem : 
  • I have a text box which is an ajax auto complete,so when i select a record i save an id into         a hidden variable.
  •  And there is a keydown event on that text box, if key down i delete the hidden variable             value.  because i don't want the user to enter any thing after he selects from the  autocomplete.
  • Now even when i press the tab button the hidden variable is cleared. 
  • Is there a way to avoid only Tab press event.?
Answer :
  • When the tab is pressed you have to read if the keydown was from the Tab button, if so you can avoid it..
$("body").on('keydown', '#textboxId', function(e) { 
  var keyCode = e.keyCode || e.which; 

  if (keyCode == 9) { 
    e.preventDefault(); 
    //IF Tab Pressed You Can Do Anything Here
  } else{ //If Its Not Tab, You Can Do It Here }
});
                


[Fixed Solution] Jquery autocomplete not working inside the ajax updatepanel

Issue : I have some auto complete text boxes with ajax calls within update panels in asp.net.
           Initially the update panel will be hidden , but when i make the visible true, 
           the autocomplete ajax controls will not work. is there a way to initialize it again after a update            panel is visible.?

Answer : Yes, there is a way. The update panel replaces the content of update panel on its update this                  means you have new content in the update panel. So the solution is to rebind the jQuery                      events like this:


Solution :  
<script type="text/javascript">
        $(function () {
            initializer();
        });


        var prmInstance = Sys.WebForms.PageRequestManager.getInstance();


        prmInstance.add_endRequest(function () {
            //you need to re-bind your jquery events here
            initializer();
        });
        function initializer() {
            $("#<%=txtrefmastguage.ClientID%>").autocomplete('Handlerold.ashx', { minChars: 1, extraParams: { "param1": "1"} })
            .result(function (event, data, formatted) {
                if (data) {


                    $("#<%= hidrefguagecode.ClientID %>").val(data[1]);
                }
                else {
                    $("#<%= hidrefguagecode.ClientID %>").val('-1');
                }
            });


        }
  

    </script>

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...