Rectangle 27 1

<p:dataTable var="car" value="#{dtFilterView.cars}" widgetVar="carsTable"
                     emptyMessage="No cars found with given criteria" 
                     filteredValue="#{dtFilterView.filteredCars}">

            <f:facet name="header">
                <p:outputPanel>
                    <h:outputText value="Search all fields:" />
                    <p:inputText id="globalFilter" onkeyup="PF('carsTable').filter()" style="width:150px" placeholder="Enter keyword"/>
                </p:outputPanel>
            </f:facet>

            <p:column id="carId" filterBy="#{car.id}" headerText="Id" footerText="contains" filterMatchMode="contains">
                <h:outputText value="#{car.id}" />
            </p:column>

            <p:column filterBy="#{car.year}" headerText="Year" footerText="lte" filterMatchMode="lte">
                <f:facet name="filter">
                    <p:spinner onchange="PF('carsTable').filter()" styleClass="year-spinner">
                        <f:converter converterId="javax.faces.Integer" />
                    </p:spinner>
                </f:facet>
                <h:outputText value="#{car.year}" />
            </p:column>

            <p:column filterBy="#{car.brand}" headerText="Brand" footerText="exact" filterMatchMode="exact">
                <f:facet name="filter">
                    <p:selectOneMenu onchange="PF('carsTable').filter()" >
                        <f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
                        <f:selectItems value="#{dtFilterView.brands}" />
                    </p:selectOneMenu>
                </f:facet>
                <h:outputText value="#{car.brand}" />
            </p:column>

            <p:column filterBy="#{car.color}" headerText="Color" footerText="in" filterMatchMode="in">
                <f:facet name="filter">
                    <p:selectCheckboxMenu label="Colors" onchange="PF('carsTable').filter()" panelStyle="width:125px" scrollHeight="150">
                        <f:selectItems value="#{dtFilterView.colors}" />
                    </p:selectCheckboxMenu>
                </f:facet>
                <h:outputText value="#{car.color}" />
            </p:column>

            <p:column filterBy="#{car.sold}" headerText="Status" footerText="equals" filterMatchMode="equals">
                <f:facet name="filter">
                    <p:selectOneButton onchange="PF('carsTable').filter()">
                        <f:converter converterId="javax.faces.Boolean" />
                        <f:selectItem itemLabel="All" itemValue="" />
                        <f:selectItem itemLabel="Sold" itemValue="true" />
                        <f:selectItem itemLabel="Sale" itemValue="false" />
                    </p:selectOneButton>
                </f:facet>
                <h:outputText value="#{car.sold ? 'Sold': 'Sale'}" />
            </p:column>

            <p:column filterBy="#{car.price}" headerText="Price" footerText="custom (min)" filterFunction="#{dtFilterView.filterByPrice}">
                <h:outputText value="#{car.price}">
                    <f:convertNumber currencySymbol="$" type="currency"/>
                </h:outputText>
            </p:column>
        </p:dataTable>
    </h:form>
    <script>
        jQuery(document).ready(function() {
            jQuery('input[id*="globalFilter"]').val('Orange');
            PF('carsTable').filter()
          });
    </script>

This is my group of code which is demonstrated default filter datatable in primefaces 5.0. The original code are appear in primefaces demo datatable filter. Different between developed code and original code are only jquery part. If you use Primefaces 4.0 or newer(5.0), you must use PF('dataTableWidgetVar').filter() instead of dataTableWidgetVar.filter()

<script>
        jQuery(document).ready(function() {
            jQuery('input[id*="globalFilter"]').val('Orange');
            PF('carsTable').filter()
          });
    </script>

not working with me it gives Cannot read property 'filter' of undefined

jsf 2 - Using Javascript to set default filter in primefaces datatable...

javascript jsf-2 primefaces datatable
Rectangle 27 2

You can't. Web browsers don't allow you to do things like filter the list by filetype or set the default directory for the file upload dialog.

As Darin and Chris have suggested, once the user has selected a file you can use javascript to parse the filename and alert the user if it doesn't look like the file is of the right type. Depending on what you are going to do with the file you should consider do something on the server side to verify that the file is valid image and not something bad .

How to restrict the files to image type using file upload in asp.net -...

asp.net file-upload
Rectangle 27 1

What I've done in the past is keep an instance of my filter/search criteria alive and pass it around as needed. In that scenario I used mostly AJAX calls to get and set data. So your criteria object in JavaScript may look like this (by default):

var criteria = {
  name : {}, 
  title : {}, 
  pageSize : 10, 
  currentPage : 1
};

Then on a successful callback from your AJAXy Delete call, call Get/LoadData and pass the criteria object along.

asp.net mvc 3 - MVC with Jquery ajax delete and how to keep the paging...

jquery asp.net-mvc-3
Rectangle 27 2

First make sure in your Configuration Object that controls is left as default (true). Secondly there is a conflict with the pagination controls and the selectors.filter's default value. So set the class of all your filter buttons and the selectors.filter to something like "filter-btn" instead.

$('#Container').mixItUp(
{   
    controls: { enable: true },
    selectors: { filter: 'filter-btn' },
    pagination: { limit: 10 }
});
<button class="filter-btn" data-filter=".clip">clip classes</button>

jquery - MixItUp Pagination not working - Stack Overflow

jquery plugins pagination
Rectangle 27 21

Normally, JSF/Facelets will set the request parameter character encoding to UTF-8 by default already when the view is created/restored. But if any request parameter is been requested before the view is been created/restored, then it's too late to set the proper character encoding. The request parameters will namely be parsed only once.

That it failed in PrimeFaces 3.x after upgrading from 2.x is caused by the new isAjaxRequest() override in PrimeFaces' PrimePartialViewContext which checks a request parameter:

@Override
public boolean isAjaxRequest() {
    return getWrapped().isAjaxRequest()
            || FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().containsKey("javax.faces.partial.ajax");
}

By default, the isAjaxRequest() (the one of Mojarra/MyFaces, as the above PrimeFaces code has obtained by getWrapped()) checks the request header as follows which does not affect the request parameter encoding as request parameters won't be parsed when a request header is obtained:

if (ajaxRequest == null) {
        ajaxRequest = "partial/ajax".equals(ctx.
            getExternalContext().getRequestHeaderMap().get("Faces-Request"));
    }

However, the isAjaxRequest() may be called by any phase listener or system event listener or some application factory before the view is been created/restored. So, when you're using PrimeFaces 3.x, then the request parameters will be parsed before the proper character encoding is been set and hence use the server's default encoding which is usually ISO-8859-1. This will mess up everything.

There are several ways to fix it:

Use a servlet filter which sets ServletRequest#setCharacterEncoding() with UTF-8. Setting the response encoding by ServletResponse#setCharacterEncoding() is by the way unnecessary as it won't be affected by this issue.

@WebFilter("/*")
public class CharacterEncodingFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        chain.doFilter(request, response);
    }

    // ...
}

You only need to take into account that HttpServletRequest#setCharacterEncoding() only sets the encoding for POST request parameters, not for GET request parameters. For GET request parameters you'd still need to configure it at server level.

If you happen to use JSF utility library OmniFaces, such a filter is already provided out the box, the CharacterEncodingFilter. Just install it as below in web.xml as first filter entry:

<filter>
    <filter-name>characterEncodingFilter</filter-name>
    <filter-class>org.omnifaces.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Reconfigure the server to use UTF-8 instead of ISO-8859-1 as default encoding. In case of Glassfish, that would be a matter of adding the following entry to <glassfish-web-app> of the /WEB-INF/glassfish-web.xml file:

<parameter-encoding default-charset="UTF-8" />

Tomcat doesn't support it. It has the URIEncoding attribute in <Context> entry, but this applies to GET requests only, not to POST requests.

Report it as a bug to PrimeFaces. Is there really any legitimate reason to check the HTTP request being an ajax request by checking a request parameter instead of a request header like as you would do for standard JSF and for example jQuery? The PrimeFaces' core.js JavaScript is doing that. It would be better if it has set it as a request header of XMLHttpRequest.

Perhaps you'll stumble upon below "solutions" somewhere on the Internet while investigating this problem. Those solutions do won't ever work in this specific case. Explanation follows.

<?xml version='1.0' encoding='UTF-8' ?>

This only tells the XML parser to use UTF-8 to decode the XML source before building the XML tree around it. The XML parser actually being used by Facelts is SAX during JSF view build time. This part has completely nothing to do with HTTP request/response encoding.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

The HTML meta tag is ignored when the page is served over HTTP via a http(s):// URI. It's only been used when the page is by the client saved as a HTML file on local disk system and then reopened by a file:// URI in browser.

<h:form accept-charset="UTF-8">

Modern browsers ignore this. This has only effect in Microsoft Internet Explorer browser. Even then it is doing it wrongly. Never use it. All real webbrowsers will instead use the charset attribute specified in the Content-Type header of the response. Even MSIE will do it the right way as long as you do not specify the accept-charset attribute.

-Dfile.encoding=UTF-8

This is only used by the Oracle(!) JVM to read and parse the Java source files.

Thanks for this great post. I encountered this issue yesterday and already isolated it to p:commandButton before finding the filter solution. Your investigation proved it. This is a serious bug since the wrong encoded characters duplicated itself with every click on the save button.

Sorry for the late reply. I have just tested your solutions today. The 2nd solution doesn't solve the problem. I also tried to use the filter but it didn't work out as well. Currently, there are 2 filters in my application: PrimeFaces's Fileupload Filter and my own filter. I added HttpServletRequest#setCharacterEncoding() into my own filter. If PrimeFaces's filter is called before the other one, will it cause the problem?

Your new problem seems to be solely related to using System.out.println() to print the submitted data. Is the stdout (there where the System.out will write to) also configured to use UTF-8? In Eclipse, you can set it in Window > Preferences > General > Workspace > Text file encoding. Please note that using both the filter and the server config isn't necessary. One of both is sufficient.

The DB persistence problem seems to be solely related to the character encoding the JDBC connection is using. Is it also configured to use UTF-8? MySQL for instance is known to incorrectly use the client platform encoding instead. Anyway to fix this and any future problems, please read balusc.blogspot.com/2009/05/

@BalusC: Actually, I have followed that post and re-created the whole database using UTF-8 charset. However, I am stuck at the part where I have to set useUnicode=yes&characterEncoding=UTF-8 for the JDBC connection. I have created my JDBC connection pool and JDBC resource using GlassFish admin console. Could you please tell me how I can apply the above 2 properties to my JDBC connections?

jsf - Unicode input retrieved via PrimeFaces input components become c...

jsf unicode primefaces character-encoding mojibake
Rectangle 27 21

Normally, JSF/Facelets will set the request parameter character encoding to UTF-8 by default already when the view is created/restored. But if any request parameter is been requested before the view is been created/restored, then it's too late to set the proper character encoding. The request parameters will namely be parsed only once.

That it failed in PrimeFaces 3.x after upgrading from 2.x is caused by the new isAjaxRequest() override in PrimeFaces' PrimePartialViewContext which checks a request parameter:

@Override
public boolean isAjaxRequest() {
    return getWrapped().isAjaxRequest()
            || FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().containsKey("javax.faces.partial.ajax");
}

By default, the isAjaxRequest() (the one of Mojarra/MyFaces, as the above PrimeFaces code has obtained by getWrapped()) checks the request header as follows which does not affect the request parameter encoding as request parameters won't be parsed when a request header is obtained:

if (ajaxRequest == null) {
        ajaxRequest = "partial/ajax".equals(ctx.
            getExternalContext().getRequestHeaderMap().get("Faces-Request"));
    }

However, the isAjaxRequest() may be called by any phase listener or system event listener or some application factory before the view is been created/restored. So, when you're using PrimeFaces 3.x, then the request parameters will be parsed before the proper character encoding is been set and hence use the server's default encoding which is usually ISO-8859-1. This will mess up everything.

There are several ways to fix it:

Use a servlet filter which sets ServletRequest#setCharacterEncoding() with UTF-8. Setting the response encoding by ServletResponse#setCharacterEncoding() is by the way unnecessary as it won't be affected by this issue.

@WebFilter("/*")
public class CharacterEncodingFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        chain.doFilter(request, response);
    }

    // ...
}

You only need to take into account that HttpServletRequest#setCharacterEncoding() only sets the encoding for POST request parameters, not for GET request parameters. For GET request parameters you'd still need to configure it at server level.

If you happen to use JSF utility library OmniFaces, such a filter is already provided out the box, the CharacterEncodingFilter. Just install it as below in web.xml as first filter entry:

<filter>
    <filter-name>characterEncodingFilter</filter-name>
    <filter-class>org.omnifaces.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Reconfigure the server to use UTF-8 instead of ISO-8859-1 as default encoding. In case of Glassfish, that would be a matter of adding the following entry to <glassfish-web-app> of the /WEB-INF/glassfish-web.xml file:

<parameter-encoding default-charset="UTF-8" />

Tomcat doesn't support it. It has the URIEncoding attribute in <Context> entry, but this applies to GET requests only, not to POST requests.

Report it as a bug to PrimeFaces. Is there really any legitimate reason to check the HTTP request being an ajax request by checking a request parameter instead of a request header like as you would do for standard JSF and for example jQuery? The PrimeFaces' core.js JavaScript is doing that. It would be better if it has set it as a request header of XMLHttpRequest.

Perhaps you'll stumble upon below "solutions" somewhere on the Internet while investigating this problem. Those solutions do won't ever work in this specific case. Explanation follows.

<?xml version='1.0' encoding='UTF-8' ?>

This only tells the XML parser to use UTF-8 to decode the XML source before building the XML tree around it. The XML parser actually being used by Facelts is SAX during JSF view build time. This part has completely nothing to do with HTTP request/response encoding.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

The HTML meta tag is ignored when the page is served over HTTP via a http(s):// URI. It's only been used when the page is by the client saved as a HTML file on local disk system and then reopened by a file:// URI in browser.

<h:form accept-charset="UTF-8">

Modern browsers ignore this. This has only effect in Microsoft Internet Explorer browser. Even then it is doing it wrongly. Never use it. All real webbrowsers will instead use the charset attribute specified in the Content-Type header of the response. Even MSIE will do it the right way as long as you do not specify the accept-charset attribute.

-Dfile.encoding=UTF-8

This is only used by the Oracle(!) JVM to read and parse the Java source files.

Thanks for this great post. I encountered this issue yesterday and already isolated it to p:commandButton before finding the filter solution. Your investigation proved it. This is a serious bug since the wrong encoded characters duplicated itself with every click on the save button.

Sorry for the late reply. I have just tested your solutions today. The 2nd solution doesn't solve the problem. I also tried to use the filter but it didn't work out as well. Currently, there are 2 filters in my application: PrimeFaces's Fileupload Filter and my own filter. I added HttpServletRequest#setCharacterEncoding() into my own filter. If PrimeFaces's filter is called before the other one, will it cause the problem?

Your new problem seems to be solely related to using System.out.println() to print the submitted data. Is the stdout (there where the System.out will write to) also configured to use UTF-8? In Eclipse, you can set it in Window > Preferences > General > Workspace > Text file encoding. Please note that using both the filter and the server config isn't necessary. One of both is sufficient.

The DB persistence problem seems to be solely related to the character encoding the JDBC connection is using. Is it also configured to use UTF-8? MySQL for instance is known to incorrectly use the client platform encoding instead. Anyway to fix this and any future problems, please read balusc.blogspot.com/2009/05/

@BalusC: Actually, I have followed that post and re-created the whole database using UTF-8 charset. However, I am stuck at the part where I have to set useUnicode=yes&characterEncoding=UTF-8 for the JDBC connection. I have created my JDBC connection pool and JDBC resource using GlassFish admin console. Could you please tell me how I can apply the above 2 properties to my JDBC connections?

jsf - Unicode input retrieved via PrimeFaces input components become c...

jsf unicode primefaces character-encoding mojibake
Rectangle 27 2

It is good idea to use same method for initial and filtered data. So the first you should do is to add string (for example) parameter 'filter' to your TypeSearchModel. Use this parameter and collect only filtered data if it is set, or initial data if it doesn't. Then I'm sure you don't want your ajax response with filtered data contains all page's HTML-markup. So the second you should do is to add condition:

if (this.Request.IsAjaxRequest())
{
    return PartialView("_ResultsOnlyWithoutLayout");
}

return View();

This will use default page's view (with layout template) for initial data and specified partial view for ajax requests.

Now you are ready to go. Add javascript handler to your filter onchange event (if it is select) or onkeyup (if it is text input) and make the $.get request to the same url but with added 'filter' parameter. You will receive html containing only filtered data without layout so you can simply replace existing data with new one (you should give data containing HTML-element some id to work with it).

For example you can do this in next way (javascript with jquery):

$("#yourContainer").load("/your-url?filter=" + $("#filter").val());
$.get(
    "/your-url?filter=" + $("#filter").val(),
    function (result) {
        $("#yourContainer").html(result);
    }
);

jquery - How can I use AJAX to filter my MVC results - Stack Overflow

jquery ajax asp.net-mvc asp.net-mvc-4
Rectangle 27 9

The problem is when posting a file over an iFrame, the "X-Requested-With" header is not set and you cannot set specific request headers for a normal form POST in Javascript. You'll have to resort to other tricks, like sending a hidden field with your POST that contains a value, and then change or override the "IsAjaxRequest" extension method to also check for this condition. How to override an existing extension method?

Probably the best option would probably be to include your own extension method with a different name, based off the default MVC extension method code with the changes to detect your iFrame upload POST, and then use your extension method anywhere where you expect to need it.

jQuery actually sets the 'X-Requested-With' header to 'XMLHttpRequest' by default. It is quite useful as long as you are careful to do all your AJAX calls over jQuery.

Depending on your needs, it's easy to setup the detection in an action filter to use it where needed, or even build it into a controller class like so:

[jQueryPartial]
public abstract class MyController : Controller
{
   public bool IsAjaxRequest { get; set; }
}
public class jQueryPartial : ActionFilterAttribute  
{  
    public override void OnActionExecuting(ActionExecutingContext filterContext)  
    { 
        // Verify if a XMLHttpRequest is fired.  
        // This can be done by checking the X-Requested-With  
        // HTTP header.  
        MyController myController = filterContext.Controller as MyController;
        if (myController != null)
        {
            if (filterContext.HttpContext.Request.Headers["X-Requested-With"] != null
                && filterContext.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                myController.IsAjaxRequest = true;
            }
            else
            {
                myController.IsAjaxRequest = false;
            }
        }
    }
}

And using the implementation:

public class SomeController : MyController
{
    public ActionResult Index()
    {
          if (IsAjaxRequest)
               DoThis();
          else
               DoThat();

          return View();
    }
}

In your code, IsAjaxRequest is always true, defeating the purpose of the code.... plus that's the same functionality that exists in the extension method... so that really doesn't help you out.

Thanks for the information. Following your lead, I ended up dynamically adding a hidden form value ("isFileUploadAjaxPost") via JQuery. In the controller, I check for that form variable. If it is present, I use TempData to store this value before calling RedirectToAction to display the "edit" view for the newly uploaded file. In the receiving action method, I check both Request.IsAjaxRequest() (as I've been doing all along) as well as my TempData value to determine if the request is "ajax" or not. Works great. Thanks!

@zowens: I fixed the code now, but yes, I realized after making it and then looking at the IsAjaxRequest extension method that is exactly the same. I adapted the code from an ActionFilter that dynamically sets the master page based on the request type which of course is somewhat less redundant than the above code.

var requestWith = filterContext.HttpContext.Request.Headers["X-Requested-With"]; myController.IsAjaxRequest = requestWith == "XMLHttpRequest;"

Detecting IsAjaxRequest() with ASP.NET MVC and JQuery Form Plugin / Fi...

jquery asp.net-mvc forms file-upload
Rectangle 27 0

How did not I found it before??!!! So obvious... Thank you man!

You are welcome. Glad to help

javascript - Set default filter column jquery datatables - Stack Overf...

javascript jquery datatables
Rectangle 27 0

Two things I'd try. First, make sure you have a link to jQuery above your script block. Use either Google's or a local copy:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

If that doesn't work, next try replacing all instances of $ in your Javascript code with jQuery:

jQuery(function(){ 
 jQuery('#tgl').daterangepicker({
    defaultDate: new Date(),
    arrows:true,
    onChange: function(){
       jQuery('#frmDate').submit()
    },
 });
});

This can help avoid conflicts with other libraries that also use $ as a variable.

hi musical_coder, thanks for your respons. it turns out I already have jquery.min.js and jquery.UI.min.js. I have edit my question. And then i have change $ with JQuery but still not work.

Try going back to basics then. Replace the inside of the jQuery block with this: jQuery('#tgl').daterangepicker({arrows: true, dateFormat: 'M d, yy'});, which I borrowed from the source code of demo page for Date Range Picker. When you do that, does it at least show the range picker, minus today's date?

Hi Mohamad- did either answer work for you? If so, please click the checkmark on one of them to accept it. Otherwise, please let us know if we can help you further.

javascript - set the current date as the default early in my datepicke...

javascript jquery jquery-ui submit daterangepicker
Rectangle 27 0

@Petur Subev Downloaded and installed latest version, didn't work for me.

javascript - Set default filter for Kendo UI Grid - Stack Overflow

javascript kendo-ui kendo-grid
Rectangle 27 0

Two things I'd try. First, make sure you have a link to jQuery above your script block. Use either Google's or a local copy:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

If that doesn't work, next try replacing all instances of $ in your Javascript code with jQuery:

jQuery(function(){ 
 jQuery('#tgl').daterangepicker({
    defaultDate: new Date(),
    arrows:true,
    onChange: function(){
       jQuery('#frmDate').submit()
    },
 });
});

This can help avoid conflicts with other libraries that also use $ as a variable.

hi musical_coder, thanks for your respons. it turns out I already have jquery.min.js and jquery.UI.min.js. I have edit my question. And then i have change $ with JQuery but still not work.

Try going back to basics then. Replace the inside of the jQuery block with this: jQuery('#tgl').daterangepicker({arrows: true, dateFormat: 'M d, yy'});, which I borrowed from the source code of demo page for Date Range Picker. When you do that, does it at least show the range picker, minus today's date?

Hi Mohamad- did either answer work for you? If so, please click the checkmark on one of them to accept it. Otherwise, please let us know if we can help you further.

javascript - set the current date as the default early in my datepicke...

javascript jquery jquery-ui submit daterangepicker
Rectangle 27 0

# 480 weeks
   #######################################
### Apache configuration directives ###
###   for mod_gzip 1.3.26.1a        ###
#######################################

##########################
### loading the module ###
##########################

# ---------------------------------------------------------------------
# load DLL / Win32:
# LoadModule gzip_module modules/ApacheModuleGzip.dll
#
# load DSO / UNIX:
# LoadModule gzip_module modules/mod_gzip.so
#
# (none of both if module has been compiled in statically;

#  the exact file name may depend upon the exact compilation method used
#  for this module)

# ---------------------------------------------------------------------

  <ifModule mod_gzip.c>

########################
### responsibilities ###
########################

# ---------------------------------------------------------------------
# use mod_gzip at all?
  mod_gzip_on                   Yes
# (you can especially enable mod_gzip inside the central server
#  configuration but disable it inside some directories ot virtual
#  hosts by using this directive.)
# ---------------------------------------------------------------------

######################################
### statically precompressed files ###
######################################

# ---------------------------------------------------------------------
# let mod_gzip perform 'partial content negotiation'?
  mod_gzip_can_negotiate        Yes
# (if this option is active and a static file is to be served in com-
#  pressed for, then mod_gzip will look for a static precompressed
#  version of this file with a defined additional extension - see next
#  directive - which would be delivered with priority. This would allow
#  for avoiding to repeatedly compress the same static file and thus
#  saving CPU time.
#  No dynamic caching of this file is provided; currently the user
#  himself is responsible for creating and updating the precompressed
#  file's content.

#  From version 1.3.19.2a mod_gzip automatically recognizes whether
#  a statically precompressed file is older than its uncompressed
#  original and in this case will serve the content of the original
#  file in uncompressed form - as to rather serve correct data than
#  outdated ones ...)

# ---------------------------------------------------------------------

# extension (suffix) for statically precompressed files
  mod_gzip_static_suffix        .gz
  AddEncoding              gzip .gz
# (effect: see previous directive; this string will be appended to the
#  name of the original file.
#  be sure to configure the encoding 'gzip' for this extension as well,
#  because mod_gzip doesn't serve the content itself but simply generates
#  an Apache internal redirection to this URL. Therefore the remaining
#  Apache configuration is responsible for setting the 'Content-Encoding'
#  header properly ...
#  prior to version 1.3.19.2a this value was not configurable.)

# ---------------------------------------------------------------------

# automatic updates for statically precompressed files
  mod_gzip_update_static        No
# (if set to 'Yes', this directive (being new in version 1.3.26.1a) would
# cause mod_gzip to automatically update an outdated version of any
# statically precompressed file during the request, i. e. compress the
# originally requested file and overwrite the precompressed variant
# file with it!
# for each automatic update of this type, mod_gzip will write a message
# of the severity 'notice' into the Apache error_log.
# while doing so, mod_gzip will directly read the original file's content.
# therefore this content cannot be interpreted by any other Apache module
# during the request. this might possibly not be what you want - hopefully
# it will be what most users want, because it works fast this way.
# use this configuration with a lot of care, and be sure that you don't
# inadvertantly cause valuable files within the URL tree to be overwritten.
# this isn't a feature to be used for mass hosting servers, especially
# because mod_gzip might experience access control problems there - the
# userid the Apache processes are running under need to have write access
# to the precompressed files of all users, which may not automatically be
# the case.)
# [mod_gzip error handling in this situation??? what will be served?]

# ---------------------------------------------------------------------

###################
### bureaucracy ###
###################

# ---------------------------------------------------------------------
# display status for mod_gzip
  mod_gzip_command_version      '/mod_gzip_status'
# (defines an URL to display the status of mod_gzip; can be specified
# individually for each installation and protected against access via
# <location> section for privacy reasons)
# ---------------------------------------------------------------------
# The status display will look like this:
#       mod_gzip is available...
#       mod_gzip_version = 1.3.26.1a
#       mod_gzip_on = Yes/No
# and thus will provide information about
# - mod_gzip being installed at the server and working correctly,
# - which version has been installed and
# - whether mod_gzip has been set 'active' for this Location
#   (-> mod_gzip_on)
# ---------------------------------------------------------------------

#######################
### data management ###
#######################

# ---------------------------------------------------------------------
# Working directory for temporary files and the compression cache
# if not specified, the following default values are used:
# [Win32=c:temp], [UNIX=/tmp]
# mod_gzip_temp_dir             /tmp
# (This directory must already exist and the userid being used for
#  running the Apache server must have read and write access to this
#  directory.
#  Unlike other Apache directives an absolute path name must be specified
#  here; a relative value will not be interpreted relatively to ServerRoot.
#  This pastname must NOT be terminated with '/'.
#  For maximum performance this directory should be located on a RAM disk,
#  if the file system isn't already being cached efficiently
# ---------------------------------------------------------------------
# Save temporary work files [Yes, No]
  mod_gzip_keep_workfiles       No
# (one file per HTTP request - set to 'yes' for debugging purpose only!)
# ---------------------------------------------------------------------

##################
### file sizes ###
##################

# ---------------------------------------------------------------------
# minimum size (in bytes) for files to be compressed
  mod_gzip_minimum_file_size    500
# (for very small files compression will produce only small absolute gains
#  [you will still save about 50% of the content, but some additional
#  500 bytes of HTTP and TCP headers will always remain uncompressed],
#  but still produce CPU load for both client and server.
#  mod_gzip will automatically set smaller values than 300 bytes for
#  this directive to exactly this value 300.)
# ---------------------------------------------------------------------
# maximum size (in bytes) for files to be compressed
  mod_gzip_maximum_file_size    500000
# (for very large files compression may eventually take rather long and
#  thus delay the start of the transmission.
#  Furthermode a limitation at this point prevents the server from
#  producing output of unlimited size in case of some endless loop
#  inside a CGI script - or even trying to compress streaming data -
#  which might otherwise cause the creation of a temporary file of
#  any size and even fill up the whole hard disk.
#  On the other hand, compression will have a much more perceivable
#  subjective effect for large files ... so be sure to fine-tune this
#  according to your requirements.)
# ---------------------------------------------------------------------
# maximum size (in bytes) for files to be compressed in memory
  mod_gzip_maximum_inmem_size   60000
# (larger files will be compressed into the temp file directory; adapt
#  this value to your server's available main memory.
#  In mod_gzip 1.3.19.x larger values will automatically be limited to
#  60000 because some operating systems are said to have problems
#  allocating more than 64 kb of memory at a time.
# ---------------------------------------------------------------------

####################
### requirements ###
####################

# (see chapter about caching for problems when using these directives.)
# ---------------------------------------------------------------------
# Required HTTP version of the client
# Possible values: 1000 = HTTP/1.0, 1001 = HTTP/1.1, ...
# This directive uses the same numeric protocol values as Apache does
# internally
  mod_gzip_min_http             1000
# (By using this directive you may exclude old browsers, search engines
#  etc. from the compression procedure: if the user agent doesn't
#  declare itself capable of understanding at least the HTTP level
#  specified here, only uncompressed data will be delivered - no matter
#  what else it claims to be able to. The value of '1001' will especially
#  exclude Netscape 4.x. and a lot of proxy servers.)
# ---------------------------------------------------------------------

# HTTP methods to be handled
# Possible values: 'GET', 'POST' or a list of both values.
  mod_gzip_handle_methods        GET POST
# (By using this directive you may particularly exclude POST requests
#  from the compression procedure. There are known cases where the
#  handling of these requests by previous mod_gzip versions could cause
#  problems.
#  Before version 1.3.19.2a this value was not configurable.)

# ---------------------------------------------------------------------

###############
### filters ###
###############

# ---------------------------------------------------------------------
# which files are to be compressed?
#
# The order of processing during each of both phases is not important,
# but to trigger the compression of a request's content this request
# a) must match at least one include rule in each of both phases and
# b) must not match an exclude rule in any of both phases.
# These rules are not minimal, they are meant to serve as example only.
#

# Note that all parameter values of the directives in this section are
# evaluated as regular expressions, and not in a case-sensitive way.

# ---------------------------------------------------------------------
# phase 1: (reqheader, uri, file, handler)
# ========================================
# NO:   special broken browsers which request for gzipped content
#       but then aren't able to handle it correctly
  mod_gzip_item_exclude         reqheader  "User-agent: Mozilla/4.0[678]"

# From version 1.3.19.2a on I advise against using filters
# for User-agents, as this will cause HTTP-Headers 'Vary: User-Agent'
# to be generated, thus making life more difficult for proxy servers.

#
# JA:   HTML-Dokumente
  mod_gzip_item_include         file       .html$
#
# NO:   include files / JavaScript & CSS (due to Netscape4 bugs)
  mod_gzip_item_exclude         file       .js$
  mod_gzip_item_exclude         file       .css$
#
# YES:  CGI scripts
  mod_gzip_item_include         file       .pl$
  mod_gzip_item_include         handler    ^cgi-script$
#
# phase 2: (mime, rspheader)
# ===========================
# YES:  normal HTML files, normal text files, Apache directory listings
  mod_gzip_item_include         mime       ^text/html$
  mod_gzip_item_include         mime       ^text/plain$
  mod_gzip_item_include         mime       ^httpd/unix-directory$
#
# NO:   images (GIF etc., will rarely ever save anything)
  mod_gzip_item_exclude         mime       ^image/
# ---------------------------------------------------------------------
# In fact mod_gzip is checking only the first 4 characters of the 1st
# operand (in case of uri even the first 2 characters only, as to
# allow for values like url).
# ---------------------------------------------------------------------
# The table for mod_gzip_item rules (include and exclude) cannot contain
# more than 256 entries; when this number is exceeded mod_gzip will
# output the message "mod_gzip: ERROR: Item index is full"
# and report a configuration error to the Apache server.
# ---------------------------------------------------------------------
# The directive values described here are meant to describe the requests
# elected for compression most exactly.
# Especially for the mime rules it has to be made clear that the HTTP
# header 'Content-Type' (that will be checked by mod_gzip for this rule)
# in some cases may contain not only a MIME type but additionally a
# character set description (charset) as well.
# If this is the case for the requests to be handled then you need to
# remove the '$' char at the end of the corresponding value so that now
# only the prefix of this value will be tested for matching.
# ---------------------------------------------------------------------

##########################
### transfer encodings ###
##########################

# ---------------------------------------------------------------------
# Allow mod_gzip to eliminate the HTTP header
#    'Transfer-encoding: chunked'
# and join the chunks to one (compressable) packet
  mod_gzip_dechunk              Yes
# (this is required for handling several types of dynamically generated
# contents, especially for CGI and SSI pages, but also for pages produced
# by some Java Servlet interpreters.
# ---------------------------------------------------------------------

###############
### logging ###
###############

# ---------------------------------------------------------------------
# Extended log format (for testing the compression effect)
  LogFormat                     "%h %l %u %t "%V %r" %<s %b mod_gzip: %{mod_gzip_result}n In:%{mod_gzip_input_size}n -< Out:%{mod_gzip_output_size}n = %{mod_gzip_compression_ratio}n pct." common_with_mod_gzip_info2
# ---------------------------------------------------------------------
# Create additional log file
  CustomLog                     logs/mod_gzip.log common_with_mod_gzip_info2
# (surely you can redefine your normal log file format, but you mal well
#  keep its format standard compatible for evaluation by standard web
#  analysis tools. So we just create another log file.)
# ---------------------------------------------------------------------
# Volume computation of the delivered files inside the Apache access_log:
# count HTTP header size (in bytes) as part of total output size
  mod_gzip_add_header_count     Yes
# (This will be more than the pure document content, but it will more
#  realistically describe the total output traffic of the HTTP request)
# ---------------------------------------------------------------------

###############
### proxies ###
###############

# ---------------------------------------------------------------------
# sending a 'Vary' HTTP header
  mod_gzip_send_vary            On
# (see chapter about caching for this directive.)
#  don't change this unless you absolutely know what you are doing!
# ---------------------------------------------------------------------

  </ifModule>

.htaccess - gzip compression code in htaccess not working - Stack Over...

.htaccess compression gzip
Rectangle 27 0

I had the same problem and I got it, that it needs the .Clear() option!

@(Html.Kendo().Grid<LocationViewModel>()
    .Name("locationGrid")
    // other bits of configuration here
    .ColumnMenu()
    .Filterable(f => f.Operators(o => o.ForString(s => s
        .Clear()
        .Contains("Contains")
        .DoesNotContain("Does not contain")
        .EndsWith("Ends with")
    )))
    // other bits of configuration here
)
  • Sorting is necessary! Put .Contains() first after .Clear() then the default is Contains!

In my case it works fine, however "equals" filter is not present no matter in which order I place it

javascript - Set default filter for Kendo UI Grid - Stack Overflow

javascript kendo-ui kendo-grid
Rectangle 27 0

<p:dataTable var="car" value="#{dtFilterView.cars}" widgetVar="carsTable"
                     emptyMessage="No cars found with given criteria" 
                     filteredValue="#{dtFilterView.filteredCars}">

            <f:facet name="header">
                <p:outputPanel>
                    <h:outputText value="Search all fields:" />
                    <p:inputText id="globalFilter" onkeyup="PF('carsTable').filter()" style="width:150px" placeholder="Enter keyword"/>
                </p:outputPanel>
            </f:facet>

            <p:column id="carId" filterBy="#{car.id}" headerText="Id" footerText="contains" filterMatchMode="contains">
                <h:outputText value="#{car.id}" />
            </p:column>

            <p:column filterBy="#{car.year}" headerText="Year" footerText="lte" filterMatchMode="lte">
                <f:facet name="filter">
                    <p:spinner onchange="PF('carsTable').filter()" styleClass="year-spinner">
                        <f:converter converterId="javax.faces.Integer" />
                    </p:spinner>
                </f:facet>
                <h:outputText value="#{car.year}" />
            </p:column>

            <p:column filterBy="#{car.brand}" headerText="Brand" footerText="exact" filterMatchMode="exact">
                <f:facet name="filter">
                    <p:selectOneMenu onchange="PF('carsTable').filter()" >
                        <f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
                        <f:selectItems value="#{dtFilterView.brands}" />
                    </p:selectOneMenu>
                </f:facet>
                <h:outputText value="#{car.brand}" />
            </p:column>

            <p:column filterBy="#{car.color}" headerText="Color" footerText="in" filterMatchMode="in">
                <f:facet name="filter">
                    <p:selectCheckboxMenu label="Colors" onchange="PF('carsTable').filter()" panelStyle="width:125px" scrollHeight="150">
                        <f:selectItems value="#{dtFilterView.colors}" />
                    </p:selectCheckboxMenu>
                </f:facet>
                <h:outputText value="#{car.color}" />
            </p:column>

            <p:column filterBy="#{car.sold}" headerText="Status" footerText="equals" filterMatchMode="equals">
                <f:facet name="filter">
                    <p:selectOneButton onchange="PF('carsTable').filter()">
                        <f:converter converterId="javax.faces.Boolean" />
                        <f:selectItem itemLabel="All" itemValue="" />
                        <f:selectItem itemLabel="Sold" itemValue="true" />
                        <f:selectItem itemLabel="Sale" itemValue="false" />
                    </p:selectOneButton>
                </f:facet>
                <h:outputText value="#{car.sold ? 'Sold': 'Sale'}" />
            </p:column>

            <p:column filterBy="#{car.price}" headerText="Price" footerText="custom (min)" filterFunction="#{dtFilterView.filterByPrice}">
                <h:outputText value="#{car.price}">
                    <f:convertNumber currencySymbol="$" type="currency"/>
                </h:outputText>
            </p:column>
        </p:dataTable>
    </h:form>
    <script>
        jQuery(document).ready(function() {
            jQuery('input[id*="globalFilter"]').val('Orange');
            PF('carsTable').filter()
          });
    </script>

This is my group of code which is demonstrated default filter datatable in primefaces 5.0. The original code are appear in primefaces demo datatable filter. Different between developed code and original code are only jquery part. If you use Primefaces 4.0 or newer(5.0), you must use PF('dataTableWidgetVar').filter() instead of dataTableWidgetVar.filter()

<script>
        jQuery(document).ready(function() {
            jQuery('input[id*="globalFilter"]').val('Orange');
            PF('carsTable').filter()
          });
    </script>

jsf 2 - Using Javascript to set default filter in primefaces datatable...

javascript jsf-2 primefaces datatable
Rectangle 27 0

I did not understand the question properly. instead of defaultDate try setDate. As I know there is no onChange event try onSelect method.

$('#tgl').daterangepicker({
    setDate: new Date(),//changed defaultDate to setDate.
    arrows:true,
    onSelect: function(){
       $('#frmDate').submit()
    }//removed comma here
 });

Hi Viraths,thanks for your respons. Previous code,i have try with setDate. But still not work. and then i try with defaultDate but still the same. I just want to set the current date as the default early in my datepicker. So that when I open this page I can filter the data according to the current date.

Did you try onSelect method instead of onChange

javascript - set the current date as the default early in my datepicke...

javascript jquery jquery-ui submit daterangepicker
Rectangle 27 0

<?php

add_action( 'init', 'optionsframework_rolescheck' );

function optionsframework_rolescheck () {
    if ( current_user_can( 'edit_theme_options' ) ) {
        // If the user can edit theme options, let the fun begin!
        add_action( 'admin_menu', 'optionsframework_add_page');
        add_action( 'admin_init', 'optionsframework_init' );
        add_action( 'wp_before_admin_bar_render', 'optionsframework_adminbar' );
    }
}

/* Loads the file for option sanitization */

add_action( 'init', 'optionsframework_load_sanitization' );

function optionsframework_load_sanitization() {
    require_once dirname( __FILE__ ) . '/options-sanitize.php';
}

/* 
 * Creates the settings in the database by looping through the array
 * we supplied in options.php.  This is a neat way to do it since
 * we won't have to save settings for headers, descriptions, or arguments.
 *
 * Read more about the Settings API in the WordPress codex:
 * http://codex.wordpress.org/Settings_API
 *
 */

function optionsframework_init() {

    // Include the required files
    require_once dirname( __FILE__ ) . '/options-interface.php';
    require_once dirname( __FILE__ ) . '/options-media-uploader.php';

    // Optionally Loads the options file from the theme
    $location = apply_filters( 'options_framework_location', array( 'options.php' ) );
    $optionsfile = locate_template( $location );

    // Load settings
    $optionsframework_settings = get_option('optionsframework' );

    // Updates the unique option id in the database if it has changed
    if ( function_exists( 'optionsframework_option_name' ) ) {
        optionsframework_option_name();
    }
    elseif ( has_action( 'optionsframework_option_name' ) ) {
        do_action( 'optionsframework_option_name' );
    }
    // If the developer hasn't explicitly set an option id, we'll use a default
    else {
        $default_themename = get_option( 'stylesheet' );
        $default_themename = preg_replace("/\W/", "_", strtolower($default_themename) );
        $default_themename = 'optionsframework_' . $default_themename;
        if ( isset( $optionsframework_settings['id'] ) ) {
            if ( $optionsframework_settings['id'] == $default_themename ) {
                // All good, using default theme id
            } else {
                $optionsframework_settings['id'] = $default_themename;
                update_option( 'optionsframework', $optionsframework_settings );
            }
        }
        else {
            $optionsframework_settings['id'] = $default_themename;
            update_option( 'optionsframework', $optionsframework_settings );
        }
    }

    // If the option has no saved data, load the defaults
    if ( ! get_option( $optionsframework_settings['id'] ) ) {
        optionsframework_setdefaults();
    }

    // Registers the settings fields and callback
    register_setting( 'optionsframework', $optionsframework_settings['id'], 'optionsframework_validate' );
    // Change the capability required to save the 'optionsframework' options group.
    add_filter( 'option_page_capability_optionsframework', 'optionsframework_page_capability' );
}

/**
 * Ensures that a user with the 'edit_theme_options' capability can actually set the options
 * See: http://core.trac.wordpress.org/ticket/14365
 *
 * @param string $capability The capability used for the page, which is manage_options by default.
 * @return string The capability to actually use.
 */

function optionsframework_page_capability( $capability ) {
    return 'edit_theme_options';
}

/* 
 * Adds default options to the database if they aren't already present.
 * May update this later to load only on plugin activation, or theme
 * activation since most people won't be editing the options.php
 * on a regular basis.
 *
 * http://codex.wordpress.org/Function_Reference/add_option
 *
 */

function optionsframework_setdefaults() {

    $optionsframework_settings = get_option( 'optionsframework' );

    // Gets the unique option id
    $option_name = $optionsframework_settings['id'];

    /* 
     * Each theme will hopefully have a unique id, and all of its options saved
     * as a separate option set.  We need to track all of these option sets so
     * it can be easily deleted if someone wishes to remove the plugin and
     * its associated data.  No need to clutter the database.  
     *
     */

    if ( isset( $optionsframework_settings['knownoptions'] ) ) {
        $knownoptions =  $optionsframework_settings['knownoptions'];
        if ( !in_array( $option_name, $knownoptions ) ) {
            array_push( $knownoptions, $option_name );
            $optionsframework_settings['knownoptions'] = $knownoptions;
            update_option( 'optionsframework', $optionsframework_settings );
        }
    } else {
        $newoptionname = array( $option_name );
        $optionsframework_settings['knownoptions'] = $newoptionname;
        update_option( 'optionsframework', $optionsframework_settings );
    }

    // Gets the default options data from the array in options.php
    $options =& _optionsframework_options();

    // If the options haven't been added to the database yet, they are added now
    $values = of_get_default_values();

    if ( isset( $values ) ) {
        add_option( $option_name, $values ); // Add option with default settings
    }
}


function optionsframework_menu_settings() {

    $menu = array(
        'page_title' => __( 'test Theme Options', 'optionsframework'),
        'menu_title' => __('test Settings', 'optionsframework'),
        'capability' => 'edit_theme_options',
        'menu_slug' => 'test-options',
        'callback' => 'optionsframework_page'
    );

    return apply_filters( 'optionsframework_menu', $menu );
}

/* Add a subpage called "Theme Options" to the appearance menu. */

function optionsframework_add_page() {

    $menu = optionsframework_menu_settings();
    $of_page = add_theme_page( $menu['page_title'], $menu['menu_title'], $menu['capability'], $menu['menu_slug'], $menu['callback'] );

    // Load the required CSS and javscript
    add_action( 'admin_enqueue_scripts', 'optionsframework_load_scripts' );
    add_action( 'admin_print_styles-' . $of_page, 'optionsframework_load_styles' );
}

/* Loads the CSS */

function optionsframework_load_styles() {
    wp_enqueue_style( 'optionsframework', OPTIONS_FRAMEWORK_DIRECTORY.'css/optionsframework.css' );
    if ( !wp_style_is( 'wp-color-picker','registered' ) ) {
        wp_register_style( 'wp-color-picker', OPTIONS_FRAMEWORK_DIRECTORY.'css/color-picker.min.css' );
    }
    wp_enqueue_style( 'wp-color-picker' );
}

/* Loads the javascript */

function optionsframework_load_scripts( $hook ) {

    $menu = optionsframework_menu_settings();

    if ( 'appearance_page_' . $menu['menu_slug'] != $hook )
        return;

    // Enqueue colorpicker scripts for versions below 3.5 for compatibility
    if ( !wp_script_is( 'wp-color-picker', 'registered' ) ) {
        wp_enqueue_script( 'iris', false, array( 'jquery','jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 );
        wp_register_script( 'wp-color-picker', OPTIONS_FRAMEWORK_DIRECTORY . 'js/color-picker.min.js', array( 'jquery', 'iris' ) );
        $colorpicker_l10n = array(
            'clear' => __( 'Clear','options_framework_theme' ),
            'defaultString' => __( 'Default', 'options_framework_theme' ),
            'pick' => __( 'Select Color', 'options_framework_theme' )
        );
        wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
    }

    // Enqueue custom option panel JS
    wp_enqueue_script( 'options-custom', OPTIONS_FRAMEWORK_DIRECTORY . 'js/options-custom.js', array( 'jquery','wp-color-picker' ) );

    // Inline scripts from options-interface.php
    add_action( 'admin_head', 'of_admin_head' );
}

function of_admin_head() {
    // Hook to add custom scripts
    do_action( 'optionsframework_custom_scripts' );
}

/* 
 * Builds out the options panel.
 *
 * If we were using the Settings API as it was likely intended we would use
 * do_settings_sections here.  But as we don't want the settings wrapped in a table,
 * we'll call our own custom optionsframework_fields.  See options-interface.php
 * for specifics on how each individual field is generated.
 *
 * Nonces are provided using the settings_fields()
 *
 */

if ( !function_exists( 'optionsframework_page' ) ) :
function optionsframework_page() {
    settings_errors(); ?>

    <div id="optionsframework-wrap" class="wrap">
    <?php screen_icon( 'themes' ); ?>
    <h2 class="nav-tab-wrapper">
        <?php echo optionsframework_tabs(); ?>
    </h2>

    <div id="optionsframework-metabox" class="metabox-holder">
        <div id="optionsframework" class="postbox">
            <form action="options.php" method="post">
            <?php settings_fields( 'optionsframework' ); ?>
            <?php optionsframework_fields(); /* Settings */ ?>
            <div id="optionsframework-submit">
                <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options', 'options_framework_theme' ); ?>" />
                <input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults', 'options_framework_theme' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!', 'options_framework_theme' ) ); ?>' );" />
                <div class="clear"></div>
            </div>
            </form>
        </div> <!-- / #container -->
    </div>
    <?php do_action( 'optionsframework_after' ); ?>
    </div> <!-- / .wrap -->

<?php
}
endif;

/**
 * Validate Options.
 *
 * This runs after the submit/reset button has been clicked and
 * validates the inputs.
 *
 * @uses $_POST['reset'] to restore default options
 */
function optionsframework_validate( $input ) {

    /*
     * Restore Defaults.
     *
     * In the event that the user clicked the "Restore Defaults"
     * button, the options defined in the theme's options.php
     * file will be added to the option for the active theme.
     */

    if ( isset( $_POST['reset'] ) ) {
        add_settings_error( 'options-framework', 'restore_defaults', __( 'Default options restored.', 'options_framework_theme' ), 'updated fade' );
        return of_get_default_values();
    }

    /*
     * Update Settings
     *
     * This used to check for $_POST['update'], but has been updated
     * to be compatible with the theme customizer introduced in WordPress 3.4
     */

    $clean = array();
    $options =& _optionsframework_options();
    foreach ( $options as $option ) {

        if ( ! isset( $option['id'] ) ) {
            continue;
        }

        if ( ! isset( $option['type'] ) ) {
            continue;
        }

        $id = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower( $option['id'] ) );

        // Set checkbox to false if it wasn't sent in the $_POST
        if ( 'checkbox' == $option['type'] && ! isset( $input[$id] ) ) {
            $input[$id] = false;
        }

        // Set each item in the multicheck to false if it wasn't sent in the $_POST
        if ( 'multicheck' == $option['type'] && ! isset( $input[$id] ) ) {
            foreach ( $option['options'] as $key => $value ) {
                $input[$id][$key] = false;
            }
        }

        // For a value to be submitted to database it must pass through a sanitization filter
        if ( has_filter( 'of_sanitize_' . $option['type'] ) ) {
            $clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option );
        }
    }

    // Hook to run after validation
    do_action( 'optionsframework_after_validate', $clean );

    return $clean;
}

/**
 * Display message when options have been saved
 */

function optionsframework_save_options_notice() {
    add_settings_error( 'options-framework', 'save_options', __( 'Options saved.', 'options_framework_theme' ), 'updated fade' );
}

add_action( 'optionsframework_after_validate', 'optionsframework_save_options_notice' );

/**
 * Format Configuration Array.
 *
 * Get an array of all default values as set in
 * options.php. The 'id','std' and 'type' keys need
 * to be defined in the configuration array. In the
 * event that these keys are not present the option
 * will not be included in this function's output.
 *
 * @return    array     Rey-keyed options configuration array.
 *
 * @access    private
 */

function of_get_default_values() {
    $output = array();
    $config =& _optionsframework_options();
    foreach ( (array) $config as $option ) {
        if ( ! isset( $option['id'] ) ) {
            continue;
        }
        if ( ! isset( $option['std'] ) ) {
            continue;
        }
        if ( ! isset( $option['type'] ) ) {
            continue;
        }
        if ( has_filter( 'of_sanitize_' . $option['type'] ) ) {
            $output[$option['id']] = apply_filters( 'of_sanitize_' . $option['type'], $option['std'], $option );
        }
    }
    return $output;
}

/**
 * Add Theme Options menu item to Admin Bar.
 */


function &_optionsframework_options() {
    static $options = null;

    if ( !$options ) {
        // Load options from options.php file (if it exists)
        $location = apply_filters( 'options_framework_location', array('options.php') );
        if ( $optionsfile = locate_template( $location ) ) {
            $maybe_options = require_once $optionsfile;
            if ( is_array($maybe_options) ) {
                $options = $maybe_options;
            } else if ( function_exists( 'optionsframework_options' ) ) {
                $options = optionsframework_options();
            }
        }

        // Allow setting/manipulating options via filters
        $options = apply_filters('of_options', $options);
    }

    return $options;
}

/**
 * Get Option.
 *
 * Helper function to return the theme option value.
 * If no value has been saved, it returns $default.
 * Needed because options are saved as serialized strings.
 */

if ( ! function_exists( 'of_get_option' ) ) {

    function of_get_option( $name, $default = false ) {
        $config = get_option( 'optionsframework' );

        if ( ! isset( $config['id'] ) ) {
            return $default;
        }

        $options = get_option( $config['id'] );

        if ( isset( $options[$name] ) ) {
            return $options[$name];
        }

        return $default;
    }
}

Can you provide the name of the file? And if it's not options.php, post the code of options.php too

yes its options.php on the root directory of theme

the last code wich I give if options.php

Using style.php and style.css on wordpress together - Stack Overflow

php css wordpress
Rectangle 27 0

I did not understand the question properly. instead of defaultDate try setDate. As I know there is no onChange event try onSelect method.

$('#tgl').daterangepicker({
    setDate: new Date(),//changed defaultDate to setDate.
    arrows:true,
    onSelect: function(){
       $('#frmDate').submit()
    }//removed comma here
 });

Hi Viraths,thanks for your respons. Previous code,i have try with setDate. But still not work. and then i try with defaultDate but still the same. I just want to set the current date as the default early in my datepicker. So that when I open this page I can filter the data according to the current date.

Did you try onSelect method instead of onChange

javascript - set the current date as the default early in my datepicke...

javascript jquery jquery-ui submit daterangepicker
Rectangle 27 0

Two things I'd try. First, make sure you have a link to jQuery above your script block. Use either Google's or a local copy:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

If that doesn't work, next try replacing all instances of $ in your Javascript code with jQuery:

jQuery(function(){ 
 jQuery('#tgl').daterangepicker({
    defaultDate: new Date(),
    arrows:true,
    onChange: function(){
       jQuery('#frmDate').submit()
    },
 });
});

This can help avoid conflicts with other libraries that also use $ as a variable.

hi musical_coder, thanks for your respons. it turns out I already have jquery.min.js and jquery.UI.min.js. I have edit my question. And then i have change $ with JQuery but still not work.

Try going back to basics then. Replace the inside of the jQuery block with this: jQuery('#tgl').daterangepicker({arrows: true, dateFormat: 'M d, yy'});, which I borrowed from the source code of demo page for Date Range Picker. When you do that, does it at least show the range picker, minus today's date?

Hi Mohamad- did either answer work for you? If so, please click the checkmark on one of them to accept it. Otherwise, please let us know if we can help you further.

javascript - set the current date as the default early in my datepicke...

javascript jquery jquery-ui submit daterangepicker
Rectangle 27 0

When you only have a single option or you are not happy with the layout you can completely customize the filter control using the "ui : func( element ) { }" overload which is present in the later versions of Kendo (e.g. v2013.1.319)

columns : [
    { field: "MyCity", width: 80, title : "City", filterable: customTextFilter },
    { field: "CreatedAt", width: 72, title: "Created", filterable: $scope.customDateFilter }
]

Here is the function that then customizes the look:

var customTextFilter =
    {
        extra : false,
        operators : { string : { contains : "Contains"}},
        ui : function( element )
        {
            var parent = element.parent();
            while( parent.children().length > 1 )
                $(parent.children()[0]).remove( );

            parent.prepend( "<input data-bind=\"value:filters[0].value\" class=\"k-textbox\" type=\"text\">" );
        }
    }

Here is an example of having two date boxes with GTE/LTE format:

var customDateFilter =
    {
        extra : true,
        operators : { },
        ui : function( element )
        {
            var parent = element.parent();
            while( parent.children().length > 1 )
                $(parent.children()[0]).remove( );

            parent.prepend(
                "On or after:<br/><span class=\"k-widget k-datepicker k-header\">" +
                "<span class=\"k-picker-wrap k-state-default\">" +
                "<input data-bind=\"value:filters[0].value\" class=\"k-input\" type=\"text\" data-role=\"datepicker\"" +
                " style=\"width: 100%\" role=\"textbox\" aria-haspopup=\"true\" aria-expanded=\"false\" aria-disabled=\"false\" " +
                " aria-readonly=\"false\" aria-label=\"Choose a date\">" +
                "<span unselectable=\"on\" class=\"k-select\" role=\"button\">" +
                "<span unselectable=\"on\" class=\"k-icon k-i-calendar\">select</span></span></span></span>" +

                "<br/>On or before:<br/>" +
                "<span class=\"k-widget k-datepicker k-header\"><span class=\"k-picker-wrap k-state-default\">" +
                "<input data-bind=\"value: filters[1].value\" class=\"k-input\" type=\"text\" data-role=\"datepicker\"" +
                " style=\"width: 100%\" role=\"textbox\" aria-haspopup=\"true\" aria-expanded=\"false\" " +
                " aria-disabled=\"false\" aria-readonly=\"false\" aria-label=\"Choose a date\">" +
                "<span unselectable=\"on\" class=\"k-select\" role=\"button\">" +
                "<span unselectable=\"on\" class=\"k-icon k-i-calendar\">select</span></span></span></span>"
            );
        }
    };

Obviously you can template out however you like and create different custom filters for Date, Boolean, etc -- note that for the Date version above if you want to set the operators correctly to say "gte" and "lte" for filter[0].operator and filter[1].operator you can just set that on the dataSource.filter attribute like so:

dataSource: {
        transport :
        {
            read : function( context )
            {
                //note that here context.filter.filters has the array
                //of applied filters -- you can write a custom RESTful call
                //such as angular $http.get( ) or use Kendo native format to
                //send filter options to server.
            }
        },
        //filter settings here initialize filter[0], filter[1], etc.
        filter : [ 
           { field : "CreatedAt", operator : "gte" },
           { field : "CreatedAt", operator : "lte" }]
   }

javascript - Set default filter for Kendo UI Grid - Stack Overflow

javascript kendo-ui kendo-grid