Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am using the browser-layout example for my application
I'm trying to add a two trees to it.
I'm trying to define the twotrees in a separate file, my main file is the layout-browser.js and i need to add this (and others) in the tabs I have in it.
The problem is that I'm using .net and the example is using php
How can I make this work in .net?
Here is my code:
Ext.require(['*']);
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'get-nodes.php'
},
root: {
text: 'Ext JS',
id: 'src',
expanded: true
},
folderSort: true,
sorters: [{
property: 'text',
direction: 'ASC'
}]
});
var tree = Ext.create('Ext.tree.Panel', {
id: 'tree',
store: store,
width: 250,
height: 300,
columnWidth: 0.5,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
appendOnly: true
}
}
// ,renderTo: document.body
});
var store2 = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'get-nodes.php'
},
root: {
text: 'Custom Ext JS',
id: 'src',
expanded: true,
children: []
},
folderSort: true,
sorters: [{
property: 'text',
direction: 'ASC'
}]
});
var tree2 = Ext.create('Ext.tree.Panel', {
id: 'tree2',
width: 250,
height: 300,
columnWidth: 0.5,
store: store2,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
appendOnly: true
}
}
// ,renderTo: document.body
});
Ext.define("Ext.app.myTwoTrees",{
extend:"Ext.panel.Panel",
width : 600,
height: 350,
layout: 'column',
items: [
tree , tree2
]
});
I call it in my tab like this:
Ext.create('Ext.app.myTwotrees')
here is the get-nodes.php
<?php
// from php manual page
function formatBytes($val, $digits = 3, $mode = 'SI', $bB = 'B'){ //$mode == 'SI'|'IEC', $bB == 'b'|'B'
$si = array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y');
$iec = array('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi');
switch(strtoupper($mode)) {
case 'SI' : $factor = 1000; $symbols = $si; break;
case 'IEC' : $factor = 1024; $symbols = $iec; break;
default : $factor = 1000; $symbols = $si; break;
}
switch($bB) {
case 'b' : $val *= 8; break;
default : $bB = 'B'; break;
}
for($i=0;$i<count($symbols)-1 && $val>=$factor;$i++)
$val /= $factor;
$p = strpos($val, '.');
if($p !== false && $p > $digits) $val = round($val);
elseif($p !== false) $val = round($val, $digits-$p);
return round($val, $digits) . ' ' . $symbols[$i] . $bB;
}
// grab the custom params
$path = isset($_REQUEST['path'])&&$_REQUEST['path'] == 'extjs' ? '../../../' : '../../';
$node = isset($_REQUEST['node']) ? $_REQUEST['node'] : '';
$isXml = isset($_REQUEST['isXml']);
if(strpos($node, '..') !== false){
die('Nice try buddy.');
}
$nodes = array();
$directory = $path.$node;
if (is_dir($directory)){
$d = dir($directory);
while($f = $d->read()){
if($f == '.' || $f == '..' || substr($f, 0, 1) == '.') continue;
$filename = $directory . '/' . $f;
date_default_timezone_set('America/Los_Angeles');
$lastmod = date('M j, Y, g:i a', filemtime($filename));
if(is_dir($directory.'/'.$f)){
$qtip = 'Type: Folder<br />Last Modified: '.$lastmod;
$nodes[] = array(
'text' => $f,
'id' => $node.'/'.$f,
'cls' => 'folder'
);
} else {
$size = formatBytes(filesize($filename), 2);
$qtip = 'Type: JavaScript File<br />Last Modified: '.$lastmod.'<br />Size: '.$size;
$nodes[] = array(
'text' => $f,
'id' => $node.'/'.$f,
'leaf' => true,
'cls' => 'file'
);
}
}
$d->close();
}
if ($isXml) {
$xmlDoc = new DOMDocument();
$root = $xmlDoc->appendChild($xmlDoc->createElement("nodes"));
foreach ($nodes as $node) {
$xmlNode = $root->appendChild($xmlDoc->createElement("node"));
$xmlNode->appendChild($xmlDoc->createElement("text", $node['text']));
$xmlNode->appendChild($xmlDoc->createElement("id", $node['id']));
$xmlNode->appendChild($xmlDoc->createElement("cls", $node['cls']));
$xmlNode->appendChild($xmlDoc->createElement("leaf", isset($node['leaf'])));
}
header("Content-Type: text/xml");
$xmlDoc->formatOutput = true;
echo $xmlDoc->saveXml();
} else {
echo json_encode($nodes);
}
I would recommend you break the problem into two pieces:
1) change url: 'get-nodes.php' to url: 'my-dotnet-url and make the .NET page return static JSON or XML (hardcode the values to the tree)
That will confirm all your javascript, resources, etc. is working properly and that you are only asking a .NET question about how to output certain data.
2) Then find a .NET example that will let you create JSON or XML from wherever you are getting data (I'm guessing probably a database). You just need the output to look like your static data that worked correctly. If you don't know much PHP or .NET learning .NET to get your output correct would be easier than trying to port over that example. If you get stuck, I'd repost a different question and ask how to output the data that results from that static file dynamically and don't have the extjs complication involved!
Hope this helps.
Try Dextop. It's an application framework for connection between ASP.NET and Ext JS.
Related
i am trying to make a youtube video downloader with php it works fine, but if the youtube video id has a character like - or _ it shows an error undefined index url,it seems like php isn't seeing this characters e,g if the youtube video id is N65RvNkZFGE it will work but if its something like wXhTHyIgQ_U it wont work cause of the underscore here's the code:
// Check whether the url is valid
if(!empty($youtubeURL) && !filter_var($youtubeURL, FILTER_VALIDATE_URL) === false){
// Get the downloader object
$downloader = $handler->getDownloader($youtubeURL);
// Set the url
$downloader->setUrl($youtubeURL);
// Validate the youtube video url
if($downloader->hasVideo()){
// Get the video download link info
$videoDownloadLink = $downloader->getVideoDownloadLink();
$videoTitle = $videoDownloadLink[0]['title'];
$videoQuality = $videoDownloadLink[0]['qualityLabel'];
$videoFormat = $videoDownloadLink[0]['format'];
$videoFileName = strtolower(str_replace(' ', '_', $videoTitle)).'.'.$videoFormat;
$downloadURL = $videoDownloadLink[0]['url'];
$fileName = preg_replace('/[^A-Za-z0-9.\_\-]/', '', basename($videoFileName));
the YouTubeDownloader.class.php file which holds the setUrl() function, the get extractVideoId() here's the code:
public function setUrl($url){
$this->video_url = $url;
}
private function extractVideoId($video_url){
//parse the url
$parsed_url = parse_url($video_url);
if($parsed_url["path"] == "youtube.com/watch"){
$this->video_url = "https://www.".$video_url;
}elseif($parsed_url["path"] == "www.youtube.com/watch"){
$this->video_url = "https://".$video_url;
}
if(isset($parsed_url["query"])){
$query_string = $parsed_url["query"];
//parse the string separated by '&' to array
parse_str($query_string, $query_arr);
if(isset($query_arr["v"])){
return $query_arr["v"];
}
}
}
It has nothing to do with "_" or "-". "n85KukOXc0A" doesn't work either. Some videos don't return the "url" field, but "cipher". It's an attempt from YouTube to obfuscate the URL.
Your $videoDownloadLink, for the video ID "wXhTHyIgQ_U", looks like:
array (
0 =>
array (
'itag' => 18,
'bitrate' => 568627,
'width' => 640,
'height' => 360,
'lastModified' => '1575010363774854',
'contentLength' => '16085704',
'quality' => 'medium',
'qualityLabel' => '360p',
'projectionType' => 'RECTANGULAR',
'averageBitrate' => 568472,
'audioQuality' => 'AUDIO_QUALITY_LOW',
'approxDurationMs' => '226371',
'audioSampleRate' => '44100',
'audioChannels' => 2,
'cipher' => 's=__L8kZ2zTIc_OfmovvG91jyFU3WN4QTERuPCxA7rHfbHICEhCrCQkmqPth6pmfw5wmrIPOT_ijWceGCWdCeK-lVYXgIARwMGkhKDv&url=https%3A%2F%2Fr4---sn-hpa7kn7s.googlevideo.com%2Fvideoplayback%3Fexpire%3D1583898090%26ei%3DigloXtGYD4bngAeu8YXQCg%26ip%3D2a00%253Aee2%253A1200%253Ae400%253A8c11%253A6897%253A2e00%253Abef0%26id%3Do-AAcaOp-0syooPWmAUuzOfm6gHGPWYCiDlfa-RNdIP34W%26itag%3D18%26source%3Dyoutube%26requiressl%3Dyes%26mm%3D31%252C26%26mn%3Dsn-hpa7kn7s%252Csn-nv47lnly%26ms%3Dau%252Conr%26mv%3Dm%26mvi%3D3%26pl%3D32%26gcr%3Dsi%26initcwndbps%3D1023750%26vprv%3D1%26mime%3Dvideo%252Fmp4%26gir%3Dyes%26clen%3D16085704%26ratebypass%3Dyes%26dur%3D226.371%26lmt%3D1575010363774854%26mt%3D1583876448%26fvip%3D4%26fexp%3D23842630%26c%3DWEB%26txp%3D5531432%26sparams%3Dexpire%252Cei%252Cip%252Cid%252Citag%252Csource%252Crequiressl%252Cgcr%252Cvprv%252Cmime%252Cgir%252Cclen%252Cratebypass%252Cdur%252Clmt%26lsparams%3Dmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%252Cinitcwndbps%26lsig%3DABSNjpQwRQIgBvV2KI0zNTv-7PsmdoRnpyNBvxeMRJIHSlKjfScxihcCIQDlHa5A-1cGAVReyssZ4YkH2nV2rdN1fel6_-Bkv7CAjA%253D%253D&sp=sig',
'title' => 'Post Malone - Circles',
'mime' => 'video/mp4',
'format' => 'mp4',
),
)
As you see, there is no "url" field, but there is a "cipher" field.
If we decode it with parse_str($videoDownloadLink[0]['cipher'], $cipher) we get:
array (
's' => '__L8kZ2zTIc_OfmovvG91jyFU3WN4QTERuPCxA7rHfbHICEhCrCQkmqPth6pmfw5wmrIPOT_ijWceGCWdCeK-lVYXgIARwMGkhKDv',
'url' => 'https://r4---sn-hpa7kn7s.googlevideo.com/videoplayback?expire=1583898090&ei=igloXtGYD4bngAeu8YXQCg&ip=2a00%3Aee2%3A1200%3Ae400%3A8c11%3A6897%3A2e00%3Abef0&id=o-AAcaOp-0syooPWmAUuzOfm6gHGPWYCiDlfa-RNdIP34W&itag=18&source=youtube&requiressl=yes&mm=31%2C26&mn=sn-hpa7kn7s%2Csn-nv47lnly&ms=au%2Conr&mv=m&mvi=3&pl=32&gcr=si&initcwndbps=1023750&vprv=1&mime=video%2Fmp4&gir=yes&clen=16085704&ratebypass=yes&dur=226.371&lmt=1575010363774854&mt=1583876448&fvip=4&fexp=23842630&c=WEB&txp=5531432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cvprv%2Cmime%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=ABSNjpQwRQIgBvV2KI0zNTv-7PsmdoRnpyNBvxeMRJIHSlKjfScxihcCIQDlHa5A-1cGAVReyssZ4YkH2nV2rdN1fel6_-Bkv7CAjA%3D%3D',
'sp' => 'sig',
)
You need to properly scramble the "s" field value and add it to the URL as the field named with the "sp" field value.
The way it needs to be scrambled changes regularly. The current way from https://www.youtube.com/yts/jsbin/player_ias-vfle4a9aa/en_US/base.js is:
var Ps = function(a) {
a = a.split("");
Os.Dw(a, 1);
Os.hZ(a, 21);
Os.An(a, 24);
Os.hZ(a, 34);
Os.hZ(a, 18);
Os.hZ(a, 63);
return a.join("")
};
var Os = {
Dw: function(a, b) {
a.splice(0, b)
},
An: function(a) {
a.reverse()
},
hZ: function(a, b) {
var c = a[0];
a[0] = a[b % a.length];
a[b % a.length] = c
}
};
Which translates into PHP as:
function scramble($a) {
$a = str_split($a);
scr_splice($a, 1);
scr_swap($a, 21);
scr_reverse($a, 24);
scr_swap($a, 34);
scr_swap($a, 18);
scr_swap($a, 63);
return implode('', $a);
}
function scr_reverse(&$a) {
$a = array_reverse($a);
}
function scr_splice(&$a, $b) {
array_splice($a, 0, $b);
}
function scr_swap(&$a, $b) {
$c = $a[0];
$a[0] = $a[$b % count($a)];
$a[$b % count($a)] = $c;
}
In your code, you need to check which type of URL you got and get the proper URL.
if (isset($videoDownloadLink[0]['url'])) {
$downloadURL = $videoDownloadLink[0]['url'];
}
else if (isset($videoDownloadLink[0]['cipher'])) {
parse_str($videoDownloadLink[0]['cipher'], $cipher);
$downloadURL = $cipher['url']."&".$cipher["sp"]."=".scramble($cipher["s"]);
}
else {
die('Error getting YouTube URL!');
}
Note:
This will only work until YouTube changes the way it's scrambled again.
I am currently working on a application where I need to parse the data posted into the server. The data is a underscore-delimited string which indicates which parent are they under.
The data posted to the server looks like this:
department: 'Sales'
s1: 'Logistics'
s1_q1_type: multiple
s1_q1: 'Q 1'
s1_q1_c1: ''
s1_q1_c2: ''
s1_q1_c3: ''
s1_q1_correct_c1: 'on'
s1_q1_correct_c2: 'on'
s1_q1_points: 10
s1_q2_type: multiple
s1_q2: 'Q 2'
s1_q2_c1: ''
s1_q2_c2: ''
s1_q2_points: 10
s2: 'Analysis'
s2_q1_type: multiple
s2_q1: 'Q 1'
s2_q1_c1: ''
s2_q1_c2: ''
s2_q1_correct_c2: 'on'
s2_q1_points: 5
s2_q2_type: multiple
s2_q2: 'Q 2'
s2_q2_c1: ''
s2_q2_c2: ''
s2_q2_points: 15
From the code above: s## are "sections", under sections there are q## (questions), then under questions there is: type, points, c## (choices) and correct answer(s). There can be multiple correct answers per question.
I need to parse the above code to an array that looks like this:
department: 'Sales',
sections: {
s1: {
title: 'Logistics',
questions: {
q1: {
title: 'Q 1',
type: multiple,
choices: {
c1: '',
c2: '',
c3: ''
},
correct: {
c1: 'on',
c2: 'on'
},
points: 10
},
q2: {
title: 'Q 2',
type: multiple,
c1: '',
c2: ''
points: 10
}
}
},
s2: {
title: 'Analysis',
questions: {
q1: {
title: 'Q 1',
type: multiple,
choices: {
c1: '',
c2: '',
c3: ''
}
correct: {
c1: 'on'
},
points: 5
},
q2: {
title: 'Q 2'
type: multiple,
c1: '',
c2: ''
points: 15
}
}
}
}
I tried using foreach and checking if weather the key is isset() but then I'm not getting anywhere.
$i = 1;
$array = array();
foreach( $_POST as $key => $value ){
if( isset( $post['s' . $i] ) ){
$array['sections'][$key] = $value;
}
$i++;
}
Any help would be greatly appreciated.
I guess this is what you looking for..
this is just roughly code.. you can take a look
$everyinput = [
's1'=>'Logistics',
's1_q1_type'=>'multiple',
's1_q1'=>'Q 1',
's1_q1_c1'=>'',
's1_q1_c2'=>'',
's1_q1_c3'=>'',
's1_q1_correct_c1'=> 'on',
's1_q1_correct_c2'=> 'on',
's1_q1_points'=>'10',
's1_q2_type'=>'multiple',
's1_q2'=>'Q 2',
's1_q2_c1'=>'',
's1_q2_c2'=>'',
's2_q1_correct_c2' =>'on',
's1_q2_points'=>10,
's2'=>'Analysis',
's2_q1_type'=>'multiple',
's2_q1'=>'Q 1',
's2_q1_c1'=>'',
's2_q1_c2'=>'',
's2_q1_points'=>5,
's2_q2_type'=>'multiple',
's2_q2'=>'Q 2',
's2_q2_c1'=>'',
's2_q2_c2'=>'',
's2_q2_points'=>15
];
$head = [];
foreach($everyinput as $key => $input) {
if ($key[0] == 's') {
if (strpos($key, "_") !== false) {
$factor = explode("_", $key);
if (count($factor) > 2) {
if ($factor[2] == "type" || $factor[2] == "points") {
$head['sections'][$factor[0]]['question'][$factor[1]][$factor[2]] = $input;
} else if($factor[2] == 'correct') {
$head['sections'][$factor[0]]['question'][$factor[1]]['correct'][$factor[3]] = $input;
} else {
$head['sections'][$factor[0]]['question'][$factor[1]]['choices'][$factor[2]] = $input;
}
} else {
$head['sections'][$factor[0]]['question'][$factor[1]]['title'] = $input;
}
} else {
$head['sections'][$key]['title'] = $input;
}
} else {
$head[$key] = $input;
}
}
dd($head);
Result
I realize there are some related questions but I couldn't find what I was looking for. I used jqgrid many times in the past but forgot how to achieve server side pagination.
here is my javascript
$("#list").jqGrid({
url: "index.php?loadData=test",
datatype: "json",
mtype: "GET",
colNames: ["id", "eNodeB_unique", "enodeB_type", "radio_freq_mod", "macroEnbId_dec representation", "num_cells"],
colModel: [
{ name: "id", width: 55 },
{ name: "enodeB_unique", width: 90 },
{ name: "enodeB_type", width: 80, align: "right" },
{ name: "radio_freq_mod", width: 80, align: "right" },
{ name: "macroEnbId_dec_rep", width: 80, align: "right" },
{ name: "num_cells", width: 150, sortable: false }
],
pager: "#pager",
rowNum: 10,
rowList: [10, 20, 30],
sortname: "id",
sortorder: "desc",
viewrecords: true,
gridview: true,
autoencode: true,
caption: "My first grid",
loadonce:false
});
and my server side code
public function getData($page, $limit, $sidx, $sord){
$query_str = "SELECT COUNT(*) AS count FROM tbl";
$prepState = $this->DBi->prepare($query_str);
$result = $this->DBi->query($prepState);
$count = $result[0]['count'];
if( $count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages){
$page = $total_pages;
}
$start = $limit * $page - $limit;
if($start < 0){
$start = 0;
}
$query_str = "SELECT * FROM tbl ORDER BY {$sidx} {$sord} LIMIT {$start}, {$limit}";
$prepState = $this->DBi->prepare($query_str);
$result = $this->DBi->query($prepState);
return $result;
}
if I keep $start and $limit in the query then i just get the inital ten results. If I take those out... then my grid shows all my results.. but there is only one page available. I have on option to click on the next page.
EDIT:
okay I realize now that I have to return this information.. I'm puzzled by the way I have to return the rows. Was JQgrid always this way?
$query_str = "SELECT * FROM enodeB ORDER BY {$sidx} {$sord} LIMIT {$start}, {$limit}";
$prepState = $this->DBi->prepare($query_str);
$result = $this->DBi->query($prepState);
$finalRows = array();
foreach($result as $row){
$finalRows[] = array('cell'=> $row);
}
return array('page' => $page, 'total' => $total_pages, 'records' => $count, 'rows' => $finalRows);
public static dynamic ToJson<T>(this IEnumerable<T> Collection, string sidx, string sord, string page, string rows, List<string> Columns)
{
return ToJson<T>(sidx, sord, page, rows, Collection, Columns);
}
private static dynamic ToJson<T>(string sidx, string sord, string page, string rows, IEnumerable<T> Collection, List<string> Columns)
{
page = page.NotNull("1"); rows = rows.NotNull("100"); sidx = sidx.NotNull("Id"); sord = sord.NotNull("asc");
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = Convert.ToInt32(rows);
int totalRecords = Collection.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
if (!Collection.IsNull())
{
Collection = Collection.ToList().OrderWith(x => x.GetPropertyValue(sidx), sord).Skip(pageSize * pageIndex).Take(pageSize);
return JsonData<T>(Collection, totalPages, page, totalRecords, Columns);
}
return BlankJson();
}
private static dynamic JsonData<T>(IEnumerable<T> collection, int totalPages, string page, int totalRecords, List<string> Columns)
{
var colsExpr = Columns.ConvertAll<PropertyInfo>(x => Extentions.GetProperty<T>(x));
var jsonData = new
{
total = totalPages,
page = page,
records = totalRecords,
rows = collection.Select(row => new { id = row.GetPropertyValue("Id") ?? Guid.NewGuid(), cell = GetValues<T>(colsExpr, row) }),
};
return jsonData;
}
public static dynamic BlankJson()
{
return new
{
total = 0,
page = 0,
records = 0,
rows = "",
};
}
private static string[] GetValues<T>(List<PropertyInfo> columns, T obj)
{
var values = new List<string>();
try
{
foreach (var x in columns)
{
var temp = x.GetValue(obj, null);
values.Add(temp != null ? temp.ToString() : string.Empty);
}
return values.ToArray();
}
catch
{
return values.ToArray();
}
}
I would like to call a function when someone clicks on the pie-chart which I built using Highchart.
My pie chart code is:
function open_risk_level_pie()
{
$chart = new Highchart();
$chart->chart->renderTo = "open_risk_level_pie";
$chart->chart->plotBackgroundColor = lightblue;
$chart->chart->plotBorderWidth = null;
$chart->chart->plotShadow = false;
$chart->title->text = "Risk Level";
$chart->tooltip->formatter = new HighchartJsExpr("function() {
return '<b>'+ this.point.name +'</b>: '+ this.point.y; }");
$chart->plotOptions->pie->allowPointSelect = 1;
$chart->plotOptions->pie->cursor = "pointer";
$chart->plotOptions->pie->dataLabels->enabled = false;
$chart->plotOptions->pie->showInLegend = 1;
$chart->plotOptions->pie->colors = array('red', 'orange', 'yellow', 'black');
$chart->credits->enabled = false;
$array = //some db access code
$high = $array[0][0];
$medium = $array[1][0];
$low = $array[2][0];
// If the array is empty
if (empty($array))
{
$data[] = array("No Data Available", 0);
}
// Otherwise
else
{
// Create the data array
foreach ($array as $row)
{
$data[] = array($row['level'], (int)$row['num']);
}
$chart->series[] = array('type' => "pie",
'name' => "Level",
'data' => $data);
}
echo "<div id=\"open_risk_level_pie\"></div>\n";
echo "<script type=\"text/javascript\">";
echo $chart->render("open_risk_level_pie");
echo "</script>\n";
}
Now I want to call a function whenever someone clicks on the pie chart. I have searched a lot, but unable to find. Some sites mentioned to use "formatter", but I failed to use it. If formatter is the solution for my question please give me steps for the above code.
Use an on click event for a slice.
Docs.
Hello I've been working on this for almost 2 hours now. I can't seem to find the error about the result not being shown on jqGrid. I tried echoing json_encode and it displayed. My jqGrid is working on my local site but not on the live one. I am passing a parameter so that it will not show other items that are not included.
Here's what I got:
//Controller
function all ($eid)
{
$page = isset($_POST['page'])?$_POST['page']:1;
$limit = isset($_POST['rows'])?$_POST['rows']:10;
$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rank';
$sord = isset($_POST['sord'])?$_POST['sord']:'';
$start = $limit*$page - $limit;
$start = ($start<0)?0:$start;
$where = "";
$searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false;
$searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false;
$searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false;
if (isset($_POST['_search']) == 'true') {
$ops = array(
'eq'=>'=',
'ne'=>'<>',
'lt'=>'<',
'le'=>'<=',
'gt'=>'>',
'ge'=>'>=',
'bw'=>'LIKE',
'bn'=>'NOT LIKE',
'in'=>'LIKE',
'ni'=>'NOT LIKE',
'ew'=>'LIKE',
'en'=>'NOT LIKE',
'cn'=>'LIKE',
'nc'=>'NOT LIKE'
);
foreach ($ops as $key=>$value){
if ($searchOper==$key) {
$ops = $value;
}
}
if($searchOper == 'eq' ) $searchString = $searchString;
if($searchOper == 'bw' || $searchOper == 'bn') $searchString .= '%';
if($searchOper == 'ew' || $searchOper == 'en' ) $searchString = '%'.$searchString;
if($searchOper == 'cn' || $searchOper == 'nc' || $searchOper == 'in' || $searchOper == 'ni') $searchString = '%'.$searchString.'%';
$where = "$searchField $ops '$searchString'";
}
if(!$sidx)
$sidx =1;
//$this->db->where('event_id', $eid);
$count = $this->db->count_all_results('table1');
if( $count > 0 ) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$query = $this->Manager_model->getcontentfromtable($start,$limit,$sidx,$sord,$where, $eid);
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
foreach($query as $row) {
$responce->rows[$i]['rank']=$row->rank;
$pace = time_to_sec($row->runner_time)/$row->runner_cat;
$pacex = sec_to_time($pace);
$responce->rows[$i]['cell']=array($row->rank,$row->runner_name,$row->runner_cat,$row->runner_bib,$row->runner_time,$pacex);
$i++;
}
echo json_encode($responce);
}
//View
<table id="list" cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>
</div>
<script type="text/javascript">
$(document).ready(function (){
jQuery("#list").jqGrid({
url: '<?php echo MAINSITE_INDEX."manager/all/$eid" ?>', //another controller function for generating data
mtype : "post", //Ajax request type. It also could be GET
datatype: "json", //supported formats XML, JSON or Arrray
colNames:['Rank','Runner Name','Category','BIB','Time','Pace'], //Grid column headings
colModel :[{
name:'rank'
,index:'rank'
,width:55
},{
name:'runner_name'
,index:'runner_name'
,width:90
,editable:true
},{
name:'runner_cat'
,index:'runner_cat'
,width:80
,align:'right'
,editable:true
},{
name:'runner_bib'
,index:'runner_bib'
,width:80
,align:'rbib'
,editable:true
},{
name:'runner_time'
,index:'runner_time'
,width:80
,align:'right'
,editable:true
},{
name:'pacex'
,index:'pacex'
,width:150
,sortable:false
,editable:false
}],
rowNum:10,
width: 1050,
height: 300,
rowList:[10,20,30],
pager: '#pager',
sortname: 'rank',
viewrecords: true,
rownumbers: true,
gridview: true,
caption:"List",
viewPagerButtons: true
}).navGrid('#pager',{edit:true,add:false,del:false});
});
</script>
Model:
function getcontentfromtable($start, $limit, $sidx, $sord, $where, $eid){
$this->db->select('*');
$this->db->limit($limit);
$this->db->where('event_id', $eid);
if($where != NULL)
$this->db->where($where,NULL,FALSE);
$this->db->order_by($sidx,$sord);
$query = $this->db->get('table1',$limit,$start);
return $query->result();
}
What is the error message...browse your page with Google chrome and press F12 or Inspect element in right hand side you can find error..please post the error also.Check your js and css file are referred path right or not...
example:-
< script src="../../../Script/jquery-ui-1.7.2.custom.min.js" type="text/javascript" >
or use Resolve URL