How to add more columns to order records in grid in KENDO [duplicate] - kendo-asp.net-mvc

This question already has answers here:
Sorting kendo grid on multiple columns
(3 answers)
Closed 5 years ago.
The question might be very simple but I have not found examples or documentation how to do order by multiple columns for KENDO grid. The part in the cshtml file is like this:
.ClientDetailTemplateId("addresses")
.DataSource(dataSource => dataSource.Ajax()
.Model(model => model.Id(m => m.Cid))
.Read(read => read.Action("SelectAddr", "Addr").Data("get_addr_grid_params"))
.PageSize(20)
.Sort(sort => sort.Add(m => m.zipcode))
)
How can I add one more column to order by?

I think you are looking for this:
.Sort(x =>
{
x.Add(y=>y.DownloadDate).Descending());
x.Add(y=>y.DueDate).Descending());
}

Related

Remove specific characters from string to tidy up URLs [duplicate]

This question already has answers here:
Extracting rootdomains from URL string in Google Sheets
(3 answers)
Closed 2 years ago.
Hi I have a column of messy URL links within Google Sheets I'm trying to clean up, I want all formats of website links to be the same so that I can run a duplicate check on them.
For example, I have a list of URLs with various http, http://, https:// etc. I am trying to use the REGEXREPLACE tool to remove all http combination elements from the column entries, however cannot get it to work. This is what I have:
Before:
http://www.website1.com/
https://website2.com/
https://www.website3.com/
And I want - After:
website.com
website2.com
website3.com
It is ok if this takes place over a number of formulas and thus columns to the end result.
try:
=ARRAYFORMULA(IFERROR(REGEXEXTRACT(INDEX(SPLIT(
REGEXREPLACE(A1:A, "https?://www.|https?://|www.", ), "/"),,1),
"\.(.+\..+)"), INDEX(IFERROR(SPLIT(
REGEXREPLACE(A1:A, "https?://www.|https?://|www.", ), "/")),,1)))
or shorter:
=INDEX(IFERROR(REGEXEXTRACT(A1:A, "^(?:https?:\/\/)?(?:www\.)?([^\/]+)")))
You can try the following formula
=ArrayFormula(regexreplace(LEFT(P1:P3,LEN(P1:P3)-1),"(.*//www.)|(.*//)",""))
Please do adjust ranges as needed.

Doctrine retrieve indexes of selected columns only

I am currently refactoring an application written in Symfony 3 and relies heavily on Doctrine ORM and I'm stuck trying to get an object/array with indexes of my selected columns.
Now I am fairly familiar with PHP PDO and as I recall a basic fetch of query results as shown below
$sth->fetchAll();
(Depending on my query) it would give me an array similar to the one below
[0] => Array
(
[name] => pear
[0] => pear
[colour] => green
[1] => green
)
[1] => Array
(
[name] => watermelon
[0] => watermelon
[colour] => pink
[1] => pink
)
With Doctrine i have tried to use several inbuilt functions with Hydration parameters
$query->getResult();
And with no luck I end up getting something like this
Array
(
[0] => Array
(
[name] => pear
[colour] => green
)
[1] => Array
(
[name] => Watermelon
[colour] => Pink
)
)
Can someone help me or point me in the right direction how to properly have this sorted out?
------Updated the question to include the full method I am currently using----
public function getDepartmentCount()
{
$qb = $this->createQueryBuilder('fruit')
->leftJoin('fruit.color','color')
$query=$qb->getQuery();
return $query->getArrayResult(); //Method that possibly needs to be changed
}
I have been able to solve this on my own after creating a custom Hydrator.
I will keep the solution here for anyone who might face a similar problem.
Below is a class for the custom Hydrator
namespace AppBundle\Doctrine;
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
use PDO;
class CustomHydrator extends AbstractHydrator
{
/**
* Hydrates all rows from the current statement instance at once.
*
* #return array
*/
protected function hydrateAllData()
{
// TODO: Implement hydrateAllData() method.
return $this->_stmt->fetchAll(PDO::FETCH_NUM);
}
}
Added this in my config file under the orm section to tell Symfony where to find the Custom Hydrator and its name
hydrators:
GridDataHydrator: AppBundle\Doctrine\CustomHydrator
And Finally executed the query using this method
$query->getResult('GridDataHydrator');

Pandas re-arranges DataFrame Columns? [duplicate]

This question already has answers here:
Pandas dict to dataframe - columns out of order?
(2 answers)
Closed 6 years ago.
Not asking how to re-arrange per se; rather noting that pandas is changing the order given:
Quite a surprise: it alphabetizes! Can you reject that and enforce your own order?
(python 2.7.11/anaconda/pandas 0.18.0/os 10.9.4)
I think it is not possible, because your input is a dictionary, the items in dictionary are not ordered. So I would just simply give:
my_order = ["dist", "dem"]
df1 = pandas.DataFrame({"dist":xm, "dem":ym}, columns=my_order)

rails drop down to select the years from current year to past four years

How do I create a drop down with a list of years beginning from current year and 4 years backward (2015, 2014... 2013)? and by default it should show the current year.
Agreed with Pavan but this would be much better
<%= select_year(Date.today, :start_year => Date.today.year, :end_year => Date.today.year-4) %>
You can use select_year. Something like below will do
<%= select_year(Date.today, :start_year => Date.today.year, :end_year => 2012) %>

How To: Add Style in OSCommerce tep_image function [duplicate]

This question already has an answer here:
Adding class attribute to osCommerce tep_image function
(1 answer)
Closed 8 years ago.
Oscommerce function tep_image:
This is the code:
tep_image(DIR_WS_IMAGES . "partners_grey_top2.png", "ksa shopping", "395", "36");
How to add style?
The fifth argument of the tep_image function in a stock version of osCommerce accepts custom parameters. If you want to add, say, a CSS class like class="product_image", you would alter your function to look like this
tep_image(DIR_WS_IMAGES . "partners_grey_top2.png", "ksa shopping", "395", "36", 'class="product_image"');